Skip to content

Commit

Permalink
add CELLiD
Browse files Browse the repository at this point in the history
  • Loading branch information
lmw123 committed Sep 5, 2022
1 parent aba8236 commit 2028a93
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 18 deletions.
37 changes: 21 additions & 16 deletions DESCRIPTION
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
8 changes: 6 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# Generated by roxygen2: do not edit by hand
export(FindSampleByMetadata)
export(DownloadDiscoData)

export(BuildIntegrationFile)
export(CELLiD)
export(DownloadDiscoData)
export(FastFindAnchors)
export(FastIntegration)
export(FindSampleByMetadata)
export(OneStopIntegration)
import(Matrix)
import(Rcpp)
import(RcppEigen)
import(jsonlite)
import(tictoc)
importFrom(Rfast,rowVars)
importFrom(dplyr,`%>%`)
importFrom(dplyr,arrange)
importFrom(dplyr,desc)
Expand Down
50 changes: 50 additions & 0 deletions R/CELLiD.R
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)
}
}

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ FastIntegration is a fast and high-capacity version of Seurat Integration. FastI

**Recent update: New functions which allow users to filter and download data in DISCO (<https://www.immunesinglecell.org/repository>), comprising 5200+ single-cell samples!**

More vignettes can be found at https://immunesinglecell.org/vignette/docs/FastIntegration/cell-type-atlas


## Requirement

FastIntegration requires the following packages:
Expand Down

0 comments on commit 2028a93

Please sign in to comment.