Description
.loadingCor <- function (dataset , avgLoading , method = " pearson" , scale = FALSE ) {
if (any(class(dataset ) == " ExpressionSet" )) {
dat <- Biobase :: exprs(dataset )
} else if (any(class(dataset ) %in% c(" SummarizedExperiment" , " RangedSummarizedExperiment" ))) {
dat <- SummarizedExperiment :: assay(dataset )
} else if (any(class(dataset ) == " matrix" )) {
dat <- dataset
} else {
stop(" 'dataset' should be one of the following objects: ExpressionSet,
SummarizedExperiment, RangedSummarizedExperiment, and matrix." )
}
if (isTRUE(scale )) {dat <- rowNorm(dat )} # row normalization
dat <- dat [apply(dat , 1 , function (x ) {! any(is.na(x ) | (x == Inf ) | (x == - Inf ))}),]
gene_common <- intersect(rownames(avgLoading ), rownames(dat ))
prcomRes <- stats :: prcomp(t(dat [gene_common ,])) # centered, but not scaled by default
loadings <- prcomRes $ rotation [, 1 : 8 ]
loading_cor <- abs(stats :: cor(avgLoading [gene_common ,], loadings [gene_common ,],
use = " pairwise.complete.obs" ,
method = method ))
return (loading_cor )
}
Reactions are currently unavailable
You can’t perform that action at this time.
GenomicSuperSignature/R/validate.R
Lines 15 to 37 in 5e73d06