Skip to content

Allow pluggable similarity measure to validate. #5

@seandavi

Description

@seandavi
  • Spearman
  • other methods from dist
  • straight function

.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)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions