Skip to content

Commit

Permalink
update R packages
Browse files Browse the repository at this point in the history
  • Loading branch information
WWXkenmo authored Jun 25, 2024
1 parent 0eedde0 commit 6060e78
Show file tree
Hide file tree
Showing 11 changed files with 1,763 additions and 66 deletions.
33 changes: 9 additions & 24 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,35 +1,20 @@
Package: NetID
Type: Package
Title: A Meta-cell Base Method to Infer Fate Specific Gene Regulatory Network from Single Cell Gene Expression Data
Title: A Meta-cell Base Method to Infer Fate Specific Gene Regulatory
Network from Single Cell Gene Expression Data
Version: 0.1.0
biocViews:
Imports:
Matrix,
lmtest,
glmnet,
RobustRankAggreg,
irlba,
rsvd,
reticulate,
Seurat,
Hmisc,
mclust,
pracma,
doParallel,
doRNG,
RaceID (>= 0.2.9),
igraph,
rARPACK
Suggests:
GENIE3,
SingleCellExperiment,
knitr,
rmarkdown
Imports: Matrix, lmtest, glmnet, RobustRankAggreg, irlba, rsvd,
reticulate, Seurat, Hmisc, mclust, pracma, doParallel, doRNG,
RaceID (>= 0.2.9), igraph, rARPACK
Suggests: GENIE3, SingleCellExperiment, knitr, rmarkdown
VignetteBuilder: knitr
Author: Weixu Wang and Dominic Grün
Maintainer: Weixu Wang <[email protected]>
Description: First sample the cells from single cell data, generate aggregate profile on pruned K-Nearest Neighbor graph, lead to a better gene expression profile to quantify gene regulations.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
NeedsCompilation: no
Packaged: 2023-09-06 08:38:49 UTC; wangweixu
Depends: R (>= 3.5.0)
37 changes: 2 additions & 35 deletions R/FateCausal.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#'
#' @export
#'
FateCausal <- function(dyn.out,L=30,alpha = 0,lambda=100,cutoff=0.25,weight=0.2,redirected=FALSE,fate_method = "palantir",aggre_method = "RobustRankAggreg",restart=FALSE,n.cores = 8,work_dir = NULL){
FateCausal <- function(dyn.out,L=30,alpha = 0,lambda=100,cutoff=0.25,weight=0.2,redirected=FALSE,fate_method = "palantir",restart=FALSE,n.cores = 8,work_dir = NULL){
if(!is.null(work_dir)){setwd(work_dir)}

#velo_m <- velo_m[apply(velo_m,1,function(x){sum(is.nan(x))})==0,]
Expand Down Expand Up @@ -195,40 +195,7 @@ FateCausal <- function(dyn.out,L=30,alpha = 0,lambda=100,cutoff=0.25,weight=0.2,
### generate the rank score
granger_net <- m1

### aggregate through SUMMA
if(aggre_method == "SUMMA"){
scaffoldNet <- as(as.matrix(t(dyn.out$skeleton$skeleton)[rownames(grn_list[[1]]),colnames(grn_list[[1]])]), "dgCMatrix")
scaffoldNet <- Matrix::summary(scaffoldNet)
prediction_m <- cbind(apply(scaffoldNet,MARGIN=1,extract,M=granger_net),apply(scaffoldNet,MARGIN=1,extract,M=GENIE3_base))
weight_vec <- summa::summa(prediction_m,"rank")@estimated_performance
weight_vec <- weight_vec / sum(weight_vec)
rm(prediction_m);gc()
grn_list_final[[i]] <- granger_net*weight_vec[1]+GENIE3_base*weight_vec[2]
}
if(aggre_method == "RobustRankAggreg"){
scaffoldNet <- as(as.matrix(t(dyn.out$skeleton$skeleton)[rownames(grn_list[[1]]),colnames(grn_list[[1]])]), "dgCMatrix")
scaffoldNet <- Matrix::summary(scaffoldNet)
prediction_m <- cbind(apply(scaffoldNet,MARGIN=1,extract,M=granger_net),apply(scaffoldNet,MARGIN=1,extract,M=GENIE3_base))
linkList <- list(c(1:nrow(prediction_m))[order(prediction_m[,1],decreasing=TRUE)],
c(1:nrow(prediction_m))[order(prediction_m[,2],decreasing=TRUE)])
linkList[[1]] <- as.character(linkList[[1]][which(prediction_m[linkList[[1]],1]!=0)])
linkList[[2]] <- as.character(linkList[[2]][which(prediction_m[linkList[[2]],2]!=0)])

r = RobustRankAggreg::rankMatrix(linkList)
score <- RobustRankAggreg::aggregateRanks(rmat = r)
scaffoldNet$x[as.integer(score$Name)] <- rankScore(1 / score$Score)
aggreGRN <- Matrix::sparseMatrix(
i = scaffoldNet$i,
j = scaffoldNet$j,
x = scaffoldNet$x,dims = dim(GENIE3_base)
)
rownames(aggreGRN) <- rownames(GENIE3_base)
colnames(aggreGRN) <- colnames(GENIE3_base)
grn_list_final[[i]] <- aggreGRN
}
if(aggre_method == "manual"){
grn_list_final[[i]] <- granger_net*(1-weight)+GENIE3_base*weight
}
grn_list_final[[i]] <- granger_net
}
names(grn_list_final) <- names(grn_list)

Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ A scalable method to infer fate specific gene regulatory network from single cel

## Tutorial

```
vignette("NetID")
```
See Jupyter Notebooks in notebook folder

## Installation
### Basic installation
Expand All @@ -23,7 +21,7 @@ pip install geosketch
```
#### install NetID
```
install.packages('NetID_0.1.0.tar.gz', repos=NULL, type='source')
devtools::install_github("WWXKenmo/NetID_package")
```
### Advance installation
#### install cellrank and palantir to realize lineage-specific GRN prediction
Expand Down
Binary file added build/vignette.rds
Binary file not shown.
5 changes: 2 additions & 3 deletions man/FateCausal.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6060e78

Please sign in to comment.