Is it possible to perform fuzzy relational product with Hail? There are usually two operations, one operate on pairs of entries with a t-norm, another pools the result into one entry through taking the minimum (harsh product)or average (mean product). A comprehensive review its here t-norm, BK product. If this is applicable, what are the Hail functions that I should use in this case?
R: loci → patient, S: patient → disease, R*S^T: loci → disease
implication <- function(a, b, type) {
switch (type,
"S#" = ifelse(a!=1 || b==1, 1, 0),
"S" = ifelse(a <= b, 1, 0),
"S*" = ifelse(a <= b, 1, b),
"G43" = min(1, b/1),
"G43" = min(1,b/1,(1-a)/(1-b)),
"L" = min(1,1-a+b),
"KDL" = min(1,1-a+a*b),
"KD" = max(1-a,b),
"EZ" = max(min(a,b),1-a),
"W" = min(max(1-a,b),max(max(a,1-b),min(b,1-a)))
)
}
triangle_subproduct <- function(R,S,type,moderate=FALSE) {
if(ncol(R) != nrow(S)) errorCondition("dimensions don't match")
R_subprod_S <- matrix(0, nrow(R), ncol(S))
for (i in 1:nrow(R)) {
for (k in 1:ncol(S))
R_subprod_S[i,k] <- ifelse(moderate,
mean(mapply(implication,R[i,],S[,k],MoreArgs=list(type=type))),
min(mapply(implication,R[i,],S[,k],MoreArgs=list(type=type))))
}
R_subprod_S
}