Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configurable number of PCs in validate #6

Open
seandavi opened this issue Feb 18, 2021 · 1 comment
Open

Allow configurable number of PCs in validate #6

seandavi opened this issue Feb 18, 2021 · 1 comment

Comments

@seandavi
Copy link
Contributor

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

@shbrief
Copy link
Owner

shbrief commented Feb 18, 2021

  1. Add the option of how many PCs you can compare with RAVs for validation
  2. Add 'scree plot' of new data as an additional guidance (in addition to scores and avg.silhouette.width)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants