-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
lmw123
committed
Sep 5, 2022
1 parent
aba8236
commit 2028a93
Showing
4 changed files
with
80 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,31 @@ | ||
Package: FastIntegration | ||
Type: Package | ||
Package: FastIntegration | ||
Title: Fast Integration of Single-cell Data | ||
Version: 1.1.0 | ||
Author: c( | ||
person(given = "Mengwei", family = "Li", email = "[email protected]", role = "aut"), | ||
person(given = "Xiaomeng", family = "Zhang", email = "[email protected]", role = "aut"), | ||
person(given = "Jinmiao", family = "Chen", email = "[email protected]", role = "aut") | ||
) | ||
Description: FastIntegrate integrates thousands of scRNA-seq datasets and outputs batch-corrected values for downstream analysis | ||
Author: c( person(given = "Mengwei", family = "Li", email = | ||
"[email protected]", role = "aut"), person(given = | ||
"Xiaomeng", family = "Zhang", email = | ||
"[email protected]", role = "aut"), person(given = | ||
"Jinmiao", family = "Chen", email = | ||
"[email protected]", role = "aut") ) | ||
Description: FastIntegrate integrates thousands of scRNA-seq datasets and | ||
outputs batch-corrected values for downstream analysis | ||
License: GPL-3 | ||
Encoding: UTF-8 | ||
LazyData: true | ||
RoxygenNote: 7.1.1 | ||
Depends: | ||
data.table, | ||
R (>= 4.0.0), | ||
Seurat (>= 4.0.0), | ||
SeuratObject (>= 4.0.0), | ||
data.table | ||
SeuratObject (>= 4.0.0) | ||
Imports: | ||
Matrix, | ||
tictoc, | ||
dplyr, | ||
Matrix, | ||
parallel, | ||
pbmcapply | ||
LinkingTo: Rcpp (>= 0.11.0), RcppEigen | ||
pbmcapply, | ||
Rfast, | ||
tictoc | ||
LinkingTo: | ||
Rcpp (>= 0.11.0), | ||
RcppEigen | ||
Encoding: UTF-8 | ||
LazyData: true | ||
RoxygenNote: 7.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#' @importFrom Rfast rowVars | ||
#' @export | ||
CELLiD = function(input.data, ref.data) { | ||
|
||
genes = intersect(rownames(input.data), rownames(ref.data)) | ||
if (length(genes) <= 2000) { | ||
stop("Too few overlapped gene between input data and reference!") | ||
} else { | ||
|
||
input.data = input.data[genes,,drop = F] | ||
ref.data = ref.data[genes,,drop = F] | ||
predicted.cell = pbmclapply( | ||
1:ncol(input.data), | ||
function(j) { | ||
predicted = as.numeric( | ||
apply(ref.data, 2, function(i) { | ||
cor(as.numeric(i), as.numeric(input.data[, j]), method = "spearman", use="complete.obs") | ||
}) | ||
) | ||
return(predicted) | ||
}, mc.cores = 10 | ||
) | ||
|
||
predicted.cell = do.call(cbind, predicted.cell) | ||
rownames(predicted.cell) = colnames(ref.data) | ||
|
||
ct = apply(predicted.cell, 2, function(x) { | ||
return(as.numeric(which(rank(-x) <=5))) | ||
}, simplify = F) | ||
|
||
predicted.cell = pbmclapply( | ||
1:ncol(input.data), function(i) { | ||
ref = ref.data[,ct[[i]]] | ||
g = which(rank(-rowVars(as.matrix(ref))) <= 2000) | ||
ref = ref[g,] | ||
input = input.data[g,i] | ||
predict = apply(ref, 2, function(i) { | ||
cor(as.numeric(i), input, method = "spearman", use="complete.obs") | ||
}) | ||
return(c(names(sort(predict, decreasing = T)[1:2]), as.numeric(sort(predict, decreasing = T)[1:2]))) | ||
}, mc.cores = 10 | ||
) | ||
|
||
predicted.cell = do.call(rbind, predicted.cell) | ||
predicted.cell[,3] = round(as.numeric(predicted.cell[,3]), 3) | ||
predicted.cell[,4] = round(as.numeric(predicted.cell[,4]), 3) | ||
return(predicted.cell) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters