Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions R/BulkProjection.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ projectBulkATAC <- function(
# Create Bulk Matrix
##################################################
bulkMat <- .safeSubset(
mat = .getAssay(subATAC, "counts"),
mat = as.matrix(.getAssay(subATAC, "counts")),
subsetRows = paste0("f", seq_along(rDGR))
)
.logThis(bulkMat, "bulkATACMat", logFile = logFile)
Expand Down Expand Up @@ -145,13 +145,15 @@ projectBulkATAC <- function(
if(!is.null(corCutOff)){
if(scaleDims){
corToDepth <- rD$corToDepth$scaled
dimsToUse <- dimsToUse[corToDepth < corCutOff]
dimsToUse <- dimsToUse[intersect(dimsToUse, which(corToDepth < corCutOff))]
}else{
corToDepth <- rD$corToDepth$none
dimsToUse <- dimsToUse[corToDepth < corCutOff]
dimsToUse <- dimsToUse[intersect(dimsToUse, which(corToDepth < corCutOff))]
}
}

simRD <- simRD[, dimsToUse, drop = FALSE]

if(embedding$params$nc != ncol(simRD)){
.logMessage("Error! Inconsistency found with matching LSI dimensions to those used in addUMAP or addTSNE",
"\nReturning with simulated reduced dimension coordinates...", verbose = TRUE, logFile = logFile)
Expand All @@ -161,8 +163,6 @@ projectBulkATAC <- function(
return(out)
}

simRD <- simRD[, dimsToUse, drop = FALSE]

}

##################################################
Expand Down
4 changes: 2 additions & 2 deletions R/Embedding.R
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ addUMAP <- function(

ArchRProj@embeddings[[name]] <- SimpleList(
df = dfEmbedding,
params = c(
params = list(
embeddingParams,
dimsToUse = dimsToUse,
scaleDims = scaleDims,
Expand All @@ -189,7 +189,7 @@ addUMAP <- function(
embeddingParams$X <- NULL
ArchRProj@embeddings[[name]] <- SimpleList(
df = dfEmbedding,
params = c(
params = list(
embeddingParams,
dimsToUse = dimsToUse,
scaleDims = scaleDims,
Expand Down
23 changes: 21 additions & 2 deletions R/HiddenUtils.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,18 @@
idxNotIn <- which(subsetRows %ni% rownames(mat))
if(length(idxNotIn) > 0){
subsetNamesNotIn <- subsetRows[idxNotIn]
matNotIn <- Matrix::sparseMatrix(i=1,j=1,x=0,dims=c(length(idxNotIn), ncol = ncol(mat)))

#check matrix class and make a matching empty matrix for the idxNotIn rows
if (class(mat)[[1]] == "dgCMatrix") {
matNotIn <- Matrix::sparseMatrix(i = 1, j = 1, x = 0, dims = c(length(idxNotIn), ncol = ncol(mat)))
} else if (class(mat)[[1]] == "matrix") {
matNotIn <- matrix(nrow = length(idxNotIn), ncol = ncol(mat), 0)
} else{
stop("Error! Argument 'mat' in .safeSubset is not either of class matrix or class dgCMatrix!")
}

rownames(matNotIn) <- subsetNamesNotIn
colnames(matNotIn) <- colnames(mat)
mat <- rbind(mat, matNotIn)
}
mat <- mat[subsetRows,]
Expand All @@ -199,7 +209,16 @@
idxNotIn <- which(subsetCols %ni% colnames(mat))
if(length(idxNotIn) > 0){
subsetNamesNotIn <- subsetCols[idxNotIn]
matNotIn <- Matrix::sparseMatrix(i=1,j=1,x=0,dims=c(nrow(mat), ncol = length(idxNotIn)))

#check matrix class and make a matching empty matrix for the idxNotIn rows
if (class(mat)[[1]] == "dgCMatrix") {
matNotIn <- Matrix::sparseMatrix(i = 1, j = 1, x = 0, dims = c(nrow(mat), ncol = length(idxNotIn)))
} else if (class(mat)[[1]] == "matrix") {
matNotIn <- matrix(nrow = nrow(mat), ncol = length(idxNotIn), 0)
} else{
stop("Error! Argument 'mat' in .safeSubset is not either of class matrix or class dgCMatrix!")
}
rownames(matNotIn) <- rownames(mat)
colnames(matNotIn) <- subsetNamesNotIn
mat <- cbind(mat, matNotIn)
}
Expand Down