message(paste0("The min. MSE = ", round(opt.par$mse.min, 3)))
message(paste0("The 1-SE MSE threshold = ", round(opt.par$mseThr, 3)))
message(paste0("min. MSE criterion gives ", opt.par$Krobust.min, " matched factors"))
message(paste0("1-SE MSE criterion gives ", opt.par$Krobust.1se, " matched factors"))
Kgrids
optParams
message("The chosen cor threshold is: ", opt.cor, ".")
message("The chosen match threshold is: ", opt.match, ".")
ve.summ <- varexp$ve.summ
ve.summ <- ve.summ[order(ve.summ$Component),]
ggplot(ve.summ, aes(x=1:nrow(ve.summ), y=Mean, ymin=Mean-SE, ymax=Mean+SE)) + 
    geom_pointrange() +
    xlab('Robust factors') + ylab('Percent variance explained') + ggtitle("Varaince explained")

Matching index matrix

varexp$indices
ve.summ <- varexp$ve.by.block.comp
ve.summ <- data.frame(ve.summ)

tmp <- paste0(round(varexp$ve.by.block$Mean, 1), ' +/- ', round(varexp$ve.by.block$SE, 1))
block.labs <- c("Block_1" = tmp[1], "Block_2" = tmp[2], "Block_3" = tmp[3], "Block_4" = tmp[4])

ggplot(ve.summ, aes(x=Component, y=Mean, ymin=Mean-SE, ymax=Mean+SE, color=Block)) +
  geom_pointrange() +
  facet_wrap(~ Block, labeller = labeller(Block = block.labs)) +
  xlab('Robust factors') + ylab('Variance explained (%)') +
  ggtitle("% variance explained by robust factors in each block")
nfactor <- ncol(robust.xw$w.med)

gfa_heatmap(
  robW = robust.xw,
  block.names=block.names,
  varIdx.by.block=varIdx.by.block,
  conf.level=0.95,
  heatmap.rep=F,
  factor.order=1:nfactor)
GFAfactorlabels <- c("rGFA")
mytitles <- paste0(GFAfactorlabels, varexp$ve.summ$Component, ': ', round(varexp$ve.summ$Mean, 1), '% Var.')
w.summ <- robust.xw$w.ci.med
names(w.summ)[names(w.summ)=="Block"] <- "GFAgroups"
names(w.summ)[names(w.summ)=="var.lab"] <- "GFAvarlabs"
for (f in 1:nfactor){
  print(
    Circbar(mydata = w.summ[w.summ$Component==varexp$ve.summ$Component[f],], 
            ebar = 2, 
            graphtitle = mytitles[f], 
            textlabel = 2, 
            minx = -0.5, 
            maxx = 0.5
            )
    )
}


kforthman/optmThrGFA documentation built on Sept. 3, 2021, 1:35 p.m.