├── ACTINN ├── ACTINN.sh ├── ACTINN_res_human.rds ├── ACTINN_res_mouse.rds └── pre-process.R ├── CHETAH ├── CHETAH.R ├── CHETAH_res_human.rds └── CHETAH_res_mouse.rds ├── CellAssign ├── CellAssign.R ├── CellAssign_res_human.rds ├── CellAssign_res_mouse.rds └── marker_file_making.R ├── Garnett ├── Garnett.R ├── Garnett_res_human.rds ├── Garnett_res_mouse.rds ├── cds_object_making.R └── marker_file_making.R ├── LICENSE ├── README.md ├── SCINA ├── SCINA.R ├── SCINA_res_human.rds └── SCINA_res_mouse.rds ├── SVM ├── SVM.py ├── SVM_res_human.rds └── SVM_res_mouse.rds ├── SingleR ├── SingleR.R ├── SingleR_res_human.rds └── SingleR_res_mouse.rds ├── scDeepSort ├── scDeepSort_res_human.rds └── scDeepSort_res_mouse.rds ├── scID ├── scID.R ├── scID_res_human.rds └── scID_res_mouse.rds ├── scMap ├── scMap.R ├── scmap_cell_res_human.rds ├── scmap_cell_res_mouse.rds ├── scmap_cluster_res_human.rds └── scmap_cluster_res_mouse.rds ├── scPred ├── scPred.R ├── scPred_res_human.rds └── scPred_res_mouse.rds └── singleCellNet ├── singleCellNet.R ├── singleCellNet_res_human.rds └── singleCellNet_res_mouse.rds /ACTINN/ACTINN.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | python actinn_format.py -i ref_ndata_train.csv.gz -o ref_ndata_train -f csv 4 | python actinn_format.py -i ndata.csv.gz -o ndata -f csv 5 | python actinn_predict.py -trs ref_ndata_train.h5 -trl ref_celltype.txt.gz -ts ndata.h5 -lr 0.0001 -ne 50 -ms 128 -pc True -op False -------------------------------------------------------------------------------- /ACTINN/ACTINN_res_human.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/ACTINN/ACTINN_res_human.rds -------------------------------------------------------------------------------- /ACTINN/ACTINN_res_mouse.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/ACTINN/ACTINN_res_mouse.rds -------------------------------------------------------------------------------- /ACTINN/pre-process.R: -------------------------------------------------------------------------------- 1 | # Single-cell transcriptomics and cell type information are both curated from literature and pre-processed generating ndata and the corresponding celltype objects. 2 | # ndata represents the normolized dgCMatrix object using Seurat. Each row represents a gene (gene symbol) and each column represents a cell (cell barcode). 3 | # celltype represents the data.frame object containg two columns, namely cell barcode and cell type. 4 | 5 | # ref_ndata represents the normolized dgCMatrix object using Seurat from HCL or MCA. Each row represents a gene (gene symbol) and each column represents a cell (cell barcode). 6 | # ref_celltype represents the data.frame object containg two columns, namely cell barcode and cell type. 7 | 8 | # training data 9 | ref_ndata<- as.matrix(ref_ndata) 10 | write.csv(ndata,file = 'ref_ndata_train.csv') 11 | R.utils::gzip('ref_ndata_train.csv',remove = F) 12 | write.table(ref_celltype,file = 'ref_celltype.txt', 13 | quote = F,sep = '\t',row.names = F,col.names = F) 14 | R.utils::gzip('ref_celltype.txt',remove = F) 15 | 16 | # test data 17 | ndata<- as.matrix(ndata) 18 | write.csv(ndata,file = 'ndata.csv') 19 | R.utils::gzip('ndata.csv',remove = F) 20 | -------------------------------------------------------------------------------- /CHETAH/CHETAH.R: -------------------------------------------------------------------------------- 1 | library(CHETAH) 2 | 3 | # Single-cell transcriptomics and cell type information are both curated from literature and pre-processed generating ndata and the corresponding celltype objects. 4 | # ndata represents the normolized dgCMatrix object using Seurat. Each row represents a gene (gene symbol) and each column represents a cell (cell barcode). 5 | # celltype represents the data.frame object containg two columns, namely cell barcode and cell type. 6 | 7 | # ref_ndata represents the normolized dgCMatrix object using Seurat from HCL or MCA. Each row represents a gene (gene symbol) and each column represents a cell (cell barcode). 8 | # ref_celltype represents the data.frame object containg two columns, namely cell barcode and cell type. 9 | 10 | # Create sce object 11 | ref_celltype<- data.frame(celltype = ref_celltype$celltype,stringsAsFactors = F) 12 | rownames(ref_celltype)<- colnames(ref_ndata) 13 | ref_sce <- SingleCellExperiment(assays = list(counts = as.matrix(ref_ndata)), 14 | colData = ref_celltype) 15 | 16 | test_sce <- SingleCellExperiment(assays = list(counts = as.matrix(test_data))) 17 | 18 | # predict 19 | test_sce <- CHETAHclassifier(input = test_sce, 20 | ref_cells = ref_sce) 21 | 22 | celltype$chetah<- test_sce$celltype_CHETAH -------------------------------------------------------------------------------- /CHETAH/CHETAH_res_human.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/CHETAH/CHETAH_res_human.rds -------------------------------------------------------------------------------- /CHETAH/CHETAH_res_mouse.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/CHETAH/CHETAH_res_mouse.rds -------------------------------------------------------------------------------- /CellAssign/CellAssign.R: -------------------------------------------------------------------------------- 1 | library(SingleCellExperiment) 2 | library(cellassign) 3 | library(scran) 4 | 5 | # Single-cell transcriptomics and cell type information are both curated from literature and pre-processed generating ndata and the corresponding celltype objects. 6 | # ndata represents the normolized dgCMatrix object using Seurat. Each row represents a gene (gene symbol) and each column represents a cell (cell barcode). 7 | # celltype represents the data.frame object containg two columns, namely cell barcode and cell type. 8 | # marker_file is obtained from [marker_file_making.R] 9 | marker_file<- marker_file[rownames(marker_file) %in% rownames(ndata),] 10 | cellname<- rep(1,ncol(marker_file)) 11 | for (i in 1:ncol(marker_file)) { 12 | d1<- marker_file[,i] 13 | if (all(d1 == 0)) { 14 | cellname[i]<- 0 15 | } 16 | } 17 | cellname<- which(cellname == 1) 18 | marker_file<- marker_file[,cellname] 19 | 20 | # making colData and rowData 21 | ndata_colData<- data.frame(Cell = celltype$cell_barcode,stringsAsFactors = F) 22 | rownames(ndata_colData)<- ndata_colData$Cell 23 | 24 | ndata_rowData <- data.frame(Gene = rownames(ndata),stringsAsFactors = F) 25 | rownames(ndata_rowData) <- ndata_rowData$Gene 26 | 27 | # Create sce object 28 | ndata_sce <- SingleCellExperiment(assays = list(counts = as.matrix(ndata)),colData = ndata_colData,rowData = ndata_rowData) 29 | ndata_sce <- computeSumFactors(ndata_sce) 30 | ndata_sce_Size_factors <- sizeFactors(ndata_sce) 31 | 32 | # cellassign 33 | ndata_cellassign_fit <- cellassign(exprs_obj = ndata_sce[rownames(marker_file),], 34 | marker_gene_info = as.matrix(marker_file), 35 | s = ndata_sce_Size_factors, 36 | learning_rate = 1e-2, 37 | shrinkage = TRUE, 38 | verbose = TRUE) 39 | -------------------------------------------------------------------------------- /CellAssign/CellAssign_res_human.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/CellAssign/CellAssign_res_human.rds -------------------------------------------------------------------------------- /CellAssign/CellAssign_res_mouse.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/CellAssign/CellAssign_res_mouse.rds -------------------------------------------------------------------------------- /CellAssign/marker_file_making.R: -------------------------------------------------------------------------------- 1 | # CellMatch is used to make marker file for each dataset. (https://github.com/ZJUFanLab/scCATCH) 2 | # select a specific species and tissue type for each dataset. 3 | # species ('Human' or 'Mouse'); tissue (e.g.,'Blood','Brain',etc.) 4 | 5 | CellMatch<- CellMatch[CellMatch$speciesType == species & CellMatch$tissueType %in% tissue & CellMatch$cancerType == 'Normal',] 6 | cell_types<- unique(CellMatch$cellName) 7 | genename<- unique(CellMatch$geneSymbol) 8 | 9 | marker_file<- as.data.frame(matrix(0,nrow = length(genename),ncol = length(cell_types)),stringsAsFactors = F) 10 | rownames(marker_file)<- genename 11 | colnames(marker_file)<- cell_types 12 | for (j in 1:length(cell_types)) { 13 | d1<- CellMatch[CellMatch$cellName == cell_types[j],]$geneSymbol 14 | d1<- unique(d1) 15 | marker_file[d1,j]<- 1 16 | } 17 | -------------------------------------------------------------------------------- /Garnett/Garnett.R: -------------------------------------------------------------------------------- 1 | library(garnett) 2 | library(org.Hs.eg.db) 3 | library(org.Mm.eg.db) 4 | 5 | # ndata_cds is obtained from [cds_object_making.R] 6 | # marker_file.txt is obtained from [marker_file_making.R] 7 | # data_db (org.Hs.eg.db for human dataset; org.Mm.eg.db for mouse datasets) 8 | 9 | garnett_classifier <- train_cell_classifier(cds = ndata_cds, 10 | marker_file = marker_file.txt, 11 | db = data_db, 12 | cds_gene_id_type = "SYMBOL", 13 | num_unknown = 50, 14 | marker_file_gene_id_type = "SYMBOL") 15 | 16 | ndata_cds <- classify_cells(ndata_cds, garnett_classifier, 17 | db = data_db, 18 | cluster_extend = TRUE, 19 | cds_gene_id_type = "SYMBOL") 20 | -------------------------------------------------------------------------------- /Garnett/Garnett_res_human.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/Garnett/Garnett_res_human.rds -------------------------------------------------------------------------------- /Garnett/Garnett_res_mouse.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/Garnett/Garnett_res_mouse.rds -------------------------------------------------------------------------------- /Garnett/cds_object_making.R: -------------------------------------------------------------------------------- 1 | library(monocle) 2 | library(BiocGenerics) 3 | 4 | # For each external testing dataset, we transformed it into a cds object for running Garnett. 5 | # Single-cell transcriptomics and cell type information are both curated from literature and pre-processed generating ndata and the corresponding celltype objects. 6 | # ndata represents the normolized dgCMatrix object using Seurat. Each row represents a gene (gene symbol) and each column represents a cell (cell barcode). 7 | # celltype represents the data.frame object containg two columns, namely cell barcode and cell type. 8 | 9 | # processing pdata 10 | pdata<- data.frame(tsne_1 = 0, tsne_2 = 0, Size_Factor = 1, FACS_type = celltype$cell_type,stringsAsFactors = F) 11 | rownames(pdata)<- celltype$cell_barcode 12 | pdata$tsne_1<- sample(x = 0:nrow(pdata),size = nrow(pdata))/nrow(pdata) 13 | pdata$tsne_2<- sample(x = 0:nrow(pdata),size = nrow(pdata))/nrow(pdata) 14 | 15 | # processing fdata 16 | fdata<- data.frame(gene_short_name = rownames(ndata),num_cells_expressed = 0,stringsAsFactors = F) 17 | genename<- fdata$gene_short_name 18 | expressed_cells<- NULL 19 | for (j in 1:length(genename)) { 20 | d1<- as.numeric(ndata[j,]) 21 | expressed_cells[j]<- length(d1[d1 > 0]) 22 | } 23 | fdata$num_cells_expressed<- expressed_cells 24 | rownames(fdata)<- fdata$gene_short_name 25 | 26 | # making cds object 27 | fdata <- new("AnnotatedDataFrame", data = fdata) 28 | pdata <- new("AnnotatedDataFrame", data = pdata) 29 | ndata_cds <- newCellDataSet(ndata,phenoData = pdata,featureData = fdata) 30 | ndata_cds<- estimateSizeFactors(ndata_cds) -------------------------------------------------------------------------------- /Garnett/marker_file_making.R: -------------------------------------------------------------------------------- 1 | library(garnett) 2 | library(org.Hs.eg.db) 3 | library(org.Mm.eg.db) 4 | 5 | # CellMatch is used to make marker file for each dataset. (https://github.com/ZJUFanLab/scCATCH) 6 | # select a specific species and tissue type for each dataset. 7 | # species ('Human' or 'Mouse'); tissue (e.g.,'Blood','Brain',etc.) 8 | CellMatch<- CellMatch[CellMatch$speciesType == species & CellMatch$tissueType %in% tissue & CellMatch$cancerType == 'Normal',] 9 | cell_types<- unique(CellMatch$cellName) 10 | 11 | marker_file.txt <- NULL 12 | for (j in 1:length(cell_types)) { 13 | marker_file.txt<- c(marker_file.txt,paste('>',cell_types[j],sep = '')) 14 | 15 | d1<- CellMatch[CellMatch$cellName == cell_types[j],]$geneSymbol 16 | d1<- unique(d1) 17 | res_markers<- NULL 18 | if (length(d1) == 1) { 19 | res_markers<- d1 20 | } 21 | if (length(d1) > 1) { 22 | res_markers<- d1[1] 23 | for (k in 2:length(d1)) { 24 | res_markers<- paste(res_markers,d1[k],sep = ', ') 25 | } 26 | } 27 | res_markers<- paste('expressed: ',res_markers,sep = '') 28 | marker_file.txt<- c(marker_file.txt,res_markers) 29 | 30 | d2<- CellMatch[CellMatch$cellName == cell_types[j],]$PMID 31 | d2<- unique(d2) 32 | res_reference<- NULL 33 | if (length(d2) == 1) { 34 | res_reference<- d2 35 | } 36 | if (length(d2) > 1) { 37 | res_reference<- d2[1] 38 | for (k in 2:length(d2)) { 39 | res_reference<- paste(res_reference,d2[k],sep = ', ') 40 | } 41 | } 42 | res_reference<- paste('references: ',res_reference,sep = '') 43 | marker_file.txt<- c(marker_file.txt,res_reference,'') 44 | } 45 | 46 | # ndata_cds is obtained from [cds_object_making.R] 47 | # check and reconstruct marker file for each dataset. 48 | # data_db (org.Hs.eg.db for human dataset; org.Mm.eg.db for mouse datasets) 49 | marker_check <- check_markers(ndata_cds, marker_file.txt, 50 | db = data_db, 51 | cds_gene_id_type = "SYMBOL", 52 | marker_file_gene_id_type = "SYMBOL") 53 | 54 | # exluding markers of Low nomination, High ambiguity, Not in db, Not in CDS. 55 | marker_check$in_cds<- as.character(marker_check$in_cds) 56 | marker_check<- marker_check[marker_check$summary == 'Low nomination?' | marker_check$summary == 'High ambiguity?' | marker_check$summary == 'Not in db' | marker_check$summary == 'Not in CDS',] 57 | CellMatch<- CellMatch[!CellMatch$geneSymbol %in% marker_check$marker_gene,] 58 | 59 | # re-making marker file 60 | 61 | marker_file.txt <- NULL 62 | for (j in 1:length(cell_types)) { 63 | marker_file.txt<- c(marker_file.txt,paste('>',cell_types[j],sep = '')) 64 | 65 | d1<- CellMatch[CellMatch$cellName == cell_types[j],]$geneSymbol 66 | d1<- unique(d1) 67 | res_markers<- NULL 68 | if (length(d1) == 1) { 69 | res_markers<- d1 70 | } 71 | if (length(d1) > 1) { 72 | res_markers<- d1[1] 73 | for (k in 2:length(d1)) { 74 | res_markers<- paste(res_markers,d1[k],sep = ', ') 75 | } 76 | } 77 | res_markers<- paste('expressed: ',res_markers,sep = '') 78 | marker_file.txt<- c(marker_file.txt,res_markers) 79 | 80 | d2<- CellMatch[CellMatch$cellName == cell_types[j],]$PMID 81 | d2<- unique(d2) 82 | res_reference<- NULL 83 | if (length(d2) == 1) { 84 | res_reference<- d2 85 | } 86 | if (length(d2) > 1) { 87 | res_reference<- d2[1] 88 | for (k in 2:length(d2)) { 89 | res_reference<- paste(res_reference,d2[k],sep = ', ') 90 | } 91 | } 92 | res_reference<- paste('references: ',res_reference,sep = '') 93 | marker_file.txt<- c(marker_file.txt,res_reference,'') 94 | } 95 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### The source code and results for different methods on annotating external testing datsets of human and mouse. 2 | 3 | |Methods |Marker-dependent|Profile-dependent|Unsure cells| 4 | |:---: |:---: |:---: | :---: | 5 | |__scDeepSort__| |YES |YES | 6 | |__CellAssign__| YES | | | 7 | |__Garnett__| YES | |YES | 8 | |__SingleR__| | YES| | 9 | |__scMap-cell__| |YES |YES | 10 | |__scMap-cluster__| |YES |YES | 11 | |__ACTINN__| |YES | | 12 | |__CHETAH__| |YES |YES | 13 | |__scID__| | YES|YES | 14 | |__SCINA__| YES | |YES | 15 | |__scPred__| | YES|YES | 16 | |__singleCellNet__| |YES | | 17 | -------------------------------------------------------------------------------- /SCINA/SCINA.R: -------------------------------------------------------------------------------- 1 | # SCINA function 2 | SCINA=function(exp,signatures,max_iter=100,convergence_n=10,convergence_rate=0.99, 3 | sensitivity_cutoff=1,rm_overlap=1,allow_unknown=1,log_file='SCINA.log'){ 4 | check.inputs=function(exp, signatures, max_iter, convergence_n, convergence_rate, sensitivity_cutoff, rm_overlap, log_file){ 5 | # Initialize parameters. 6 | quality=1 7 | def_max_iter=1000 8 | def_conv_n=10 9 | def_conv_rate=0.99 10 | def_dummycut=0.33 11 | allgenes=row.names(exp) 12 | # Check sequence matrices. 13 | if (any(is.na(exp))){ 14 | cat('NA exists in expression matrix.',file=log_file,append=T) 15 | cat('\n',file=log_file,append=T) 16 | quality=0 17 | } 18 | # Check signatures. 19 | if (any(is.na(signatures))){ 20 | cat('Null cell type signature genes.',file=log_file,append=T) 21 | cat('\n',file=log_file,append=T) 22 | quality=0 23 | }else{ 24 | signatures=sapply(signatures,function(x) unique(x[(!is.na(x)) & (x %in% allgenes)]),simplify=F) 25 | # Remove duplicate genes. 26 | if(rm_overlap==1){ 27 | tmp=table(unlist(signatures)) 28 | signatures=sapply(signatures,function(x) x[x %in% names(tmp[tmp==1])],simplify=F) 29 | } 30 | # Check if any genes have all 0 counts 31 | signatures=sapply(signatures,function(x) x[apply(exp[x,,drop=F],1,sd)>0],simplify=F) 32 | } 33 | # Clean other parameters. 34 | if (is.na(convergence_n)){ 35 | cat('Using convergence_n=default',file=log_file,append=T) 36 | cat('\n',file=log_file,append=T) 37 | convergence_n=def_conv_n 38 | } 39 | if (is.na(max_iter)){ 40 | cat('Using max_iter=default',file=log_file,append=T) 41 | cat('\n',file=log_file,append=T) 42 | max_iter=def_max_iter 43 | }else{ 44 | if (max_iter1e200]=1e200 69 | tmp[tmp<1e-200]=1e-200 70 | return(tmp) 71 | } 72 | cat('Start running SCINA.',file=log_file,append=F) 73 | cat('\n',file=log_file,append=T) 74 | #Create a status file for the webserver 75 | status_file=paste(log_file,'status',sep='.') 76 | all_sig=unique(unlist(signatures)) 77 | # Create low-expression signatures. 78 | invert_sigs=grep('^low_',all_sig,value=T) 79 | if(!identical(invert_sigs, character(0))){ 80 | cat('Converting expression matrix for low_genes.',file=log_file,append=T) 81 | cat('\n',file=log_file,append=T) 82 | invert_sigs_2add=unlist(lapply(invert_sigs,function(x) strsplit(x,'_')[[1]][2])) 83 | invert_sigs=invert_sigs[invert_sigs_2add%in%row.names(exp)] 84 | invert_sigs_2add=invert_sigs_2add[invert_sigs_2add%in%row.names(exp)] 85 | sub_exp=-exp[invert_sigs_2add,,drop=F] 86 | row.names(sub_exp)=invert_sigs 87 | exp=rbind(exp,sub_exp) 88 | rm(sub_exp,all_sig,invert_sigs,invert_sigs_2add) 89 | } 90 | # Check input parameters. 91 | quality=check.inputs(exp,signatures,max_iter,convergence_n,convergence_rate,sensitivity_cutoff,rm_overlap,log_file) 92 | if(quality$qual==0){ 93 | cat('EXITING due to invalid parameters.',file=log_file,append=T) 94 | cat('\n',file=log_file,append=T) 95 | cat('0',file=status_file,append=F) 96 | stop('SCINA stopped.') 97 | } 98 | signatures=quality$sig 99 | max_iter=quality$para[1] 100 | convergence_n=quality$para[2] 101 | convergence_rate=quality$para[3] 102 | sensitivity_cutoff=quality$para[4] 103 | # Initialize variables. 104 | exp=as.matrix(exp) 105 | exp=exp[unlist(signatures),,drop=F] 106 | labels=matrix(0,ncol=convergence_n, nrow=dim(exp)[2]) 107 | unsatisfied=1 108 | if(allow_unknown==1){ 109 | tao=rep(1/(length(signatures)+1),length(signatures)) 110 | }else{tao=rep(1/(length(signatures)),length(signatures))} 111 | theta=list() 112 | for(i in 1:length(signatures)){ 113 | theta[[i]]=list() 114 | theta[[i]]$mean=t(apply(exp[signatures[[i]],,drop=F],1,function(x) quantile(x,c(0.7,0.3)))) 115 | tmp=apply(exp[signatures[[i]],,drop=F],1,var) 116 | theta[[i]]$sigma1=diag(tmp,ncol = length(tmp)) 117 | theta[[i]]$sigma2=theta[[i]]$sigma1 118 | } 119 | theta1<- NULL 120 | for(marker_set in 1:length(theta)){ 121 | if(rlang::is_empty(theta[[marker_set]]$sigma1) == TRUE){ 122 | theta1 <- c(theta1,marker_set) 123 | } 124 | } 125 | if (!is.null(theta1)) { 126 | theta<- theta[-theta1] 127 | signatures<- signatures[-theta1] 128 | tao<- tao[-theta1] 129 | } 130 | sigma_min=min(sapply(theta,function(x) min(c(diag(x$sigma1),diag(x$sigma2)))))/100 131 | remove_times=0 132 | # Run SCINA algorithm. 133 | while(unsatisfied==1){ 134 | prob_mat=matrix(tao,ncol=dim(exp)[2],nrow=length(tao)) 135 | row.names(prob_mat)=names(signatures) 136 | iter=0 137 | labels_i=1 138 | remove_times=remove_times+1 139 | while(iter 0) { 151 | prob_mat<- prob_mat[-prob_mat1,] 152 | theta<- theta[-prob_mat1] 153 | signatures<- signatures[-prob_mat1] 154 | } 155 | prob_mat=t(t(prob_mat)/(1-sum(tao)+colSums(prob_mat))) 156 | # M step: update sample distributions. 157 | tao=rowMeans(prob_mat) 158 | for(i in 1:length(signatures)){ 159 | theta[[i]]$mean[,1]=(exp[signatures[[i]],]%*%prob_mat[i,])/sum(prob_mat[i,]) 160 | theta[[i]]$mean[,2]=(exp[signatures[[i]],]%*%(1-prob_mat[i,]))/sum(1-prob_mat[i,]) 161 | keep=theta[[i]]$mean[,1]<=theta[[i]]$mean[,2] 162 | if(any(keep)){ 163 | theta[[i]]$mean[keep,1]=rowMeans(exp[signatures[[i]][keep],,drop=F]) 164 | theta[[i]]$mean[keep,2]=theta[[i]]$mean[keep,1] 165 | } 166 | tmp1=t((exp[signatures[[i]],,drop=F]-theta[[i]]$mean[,1])^2) 167 | tmp2=t((exp[signatures[[i]],,drop=F]-theta[[i]]$mean[,2])^2) 168 | diag(theta[[i]]$sigma1)=diag(theta[[i]]$sigma2)= 169 | colSums(tmp1*prob_mat[i,]+tmp2*(1-prob_mat[i,]))/dim(prob_mat)[2] 170 | diag(theta[[i]]$sigma1)[diag(theta[[i]]$sigma1)=convergence_rate){ 176 | cat('Job finished successfully.',file=log_file,append=T) 177 | cat('\n',file=log_file,append=T) 178 | cat('1',file=status_file,append=F) 179 | break 180 | } 181 | labels_i=labels_i+1 182 | if(labels_i==convergence_n+1){ 183 | labels_i=1 184 | } 185 | if(iter==max_iter){ 186 | cat('Maximum iterations, breaking out.',file=log_file,append=T) 187 | cat('\n',file=log_file,append=T) 188 | } 189 | } 190 | #Build result matrices. 191 | colnames(prob_mat)=colnames(exp) 192 | row.names(prob_mat)=names(signatures) 193 | row.names(labels)=colnames(exp) 194 | # Attempt to remove unused signatures. 195 | dummytest=sapply(1:length(signatures),function(i) mean(theta[[i]]$mean[,1]-theta[[i]]$mean[,2]==0)) 196 | if(all(dummytest<=sensitivity_cutoff)){ 197 | unsatisfied=0 198 | }else{ 199 | rev=which(dummytest>sensitivity_cutoff); 200 | cat(paste('Remove dummy signatures:',rev,sep=' '),file=log_file,append=T) 201 | cat('\n',file=log_file,append=T) 202 | signatures=signatures[-rev] 203 | tmp=1-sum(tao) 204 | tao=tao[-rev] 205 | tao=tao/(tmp+sum(tao)) 206 | theta=theta[-rev] 207 | } 208 | } 209 | return(list(cell_labels=c("unknown",names(signatures))[1+labels[,labels_i]],probabilities=prob_mat)) 210 | } 211 | 212 | 213 | # CellMatch is used to make marker file for each dataset. (https://github.com/ZJUFanLab/scCATCH) 214 | # select a specific species and tissue type for each dataset. 215 | # species ('Human' or 'Mouse'); tissue (e.g.,'Blood','Brain',etc.) 216 | 217 | CellMatch<- CellMatch[CellMatch$speciesType == species & CellMatch$tissueType %in% tissue & CellMatch$cancerType == 'Normal',] 218 | cellname<- unique(CellMatch$cellName) 219 | cell_marker<- list() 220 | for (j in 1:length(cellname)) { 221 | cell_marker[[j]]<- CellMatch[CellMatch$cellName == cellname[j],]$geneSymbol 222 | names(cell_marker)[j]<- cellname[j] 223 | } 224 | 225 | # Single-cell transcriptomics and cell type information are both curated from literature and pre-processed generating ndata and the corresponding celltype objects. 226 | # ndata represents the normolized dgCMatrix object using Seurat. Each row represents a gene (gene symbol) and each column represents a cell (cell barcode). 227 | # celltype represents the data.frame object containg two columns, namely cell barcode and cell type. 228 | 229 | test_res<- SCINA(exp = as.matrix(ndata),signatures = cell_marker) 230 | celltype$SCINA<- test_res$cell_labels 231 | -------------------------------------------------------------------------------- /SCINA/SCINA_res_human.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/SCINA/SCINA_res_human.rds -------------------------------------------------------------------------------- /SCINA/SCINA_res_mouse.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/SCINA/SCINA_res_mouse.rds -------------------------------------------------------------------------------- /SVM/SVM.py: -------------------------------------------------------------------------------- 1 | from sklearn.svm import SVC 2 | import os 3 | 4 | import argparse 5 | import pandas as pd 6 | from sklearn.decomposition import PCA 7 | from time import time 8 | from scipy.sparse import csr_matrix, vstack 9 | from pathlib import Path 10 | import numpy as np 11 | 12 | 13 | def get_map_dict(species_data_path: Path, tissue): 14 | map_df = pd.read_excel(species_data_path / 'map.xlsx') 15 | # {num: {test_cell1: {train_cell1, train_cell2}, {test_cell2:....}}, num_2:{}...} 16 | map_dic = dict() 17 | for idx, row in enumerate(map_df.itertuples()): 18 | if getattr(row, 'Tissue') == tissue: 19 | num = getattr(row, 'num') 20 | test_celltype = getattr(row, 'Celltype') 21 | train_celltype = getattr(row, '_5') 22 | if map_dic.get(getattr(row, 'num')) is None: 23 | map_dic[num] = dict() 24 | map_dic[num][test_celltype] = set() 25 | elif map_dic[num].get(test_celltype) is None: 26 | map_dic[num][test_celltype] = set() 27 | map_dic[num][test_celltype].add(train_celltype) 28 | return map_dic 29 | 30 | 31 | def get_id_2_gene(gene_statistics_path, species_data_path, tissue, train_dir: str): 32 | if not gene_statistics_path.exists(): 33 | data_path = species_data_path / train_dir 34 | data_files = data_path.glob(f'*{tissue}*_data.csv') 35 | genes = None 36 | for file in data_files: 37 | data = pd.read_csv(file, dtype=np.str, header=0).values[:, 0] 38 | if genes is None: 39 | genes = set(data) 40 | else: 41 | genes = genes | set(data) 42 | id2gene = list(genes) 43 | id2gene.sort() 44 | with open(gene_statistics_path, 'w', encoding='utf-8') as f: 45 | for gene in id2gene: 46 | f.write(gene + '\r\n') 47 | else: 48 | id2gene = [] 49 | with open(gene_statistics_path, 'r', encoding='utf-8') as f: 50 | for line in f: 51 | id2gene.append(line.strip()) 52 | return id2gene 53 | 54 | 55 | def get_id_2_label(cell_statistics_path, species_data_path, tissue, train_dir: str): 56 | if not cell_statistics_path.exists(): 57 | data_path = species_data_path / train_dir 58 | cell_files = data_path.glob(f'*{tissue}*_celltype.csv') 59 | cell_types = set() 60 | for file in cell_files: 61 | df = pd.read_csv(file, dtype=np.str, header=0) 62 | df['Cell_type'] = df['Cell_type'].map(str.strip) 63 | cell_types = set(df.values[:, 2]) | cell_types 64 | # cell_types = set(pd.read_csv(file, dtype=np.str, header=0).values[:, 2]) | cell_types 65 | id2label = list(cell_types) 66 | with open(cell_statistics_path, 'w', encoding='utf-8') as f: 67 | for cell_type in id2label: 68 | f.write(cell_type + '\r\n') 69 | else: 70 | id2label = [] 71 | with open(cell_statistics_path, 'r', encoding='utf-8') as f: 72 | for line in f: 73 | id2label.append(line.strip()) 74 | return id2label 75 | 76 | 77 | def load_data(params): 78 | random_seed = params.random_seed 79 | dense_dim = params.dense_dim 80 | train = params.train_dataset 81 | test = params.test_dataset 82 | tissue = params.tissue 83 | 84 | proj_path = Path(__file__).parent.resolve().parent.resolve() 85 | species_data_path = proj_path / 'data' / params.species 86 | statistics_path = species_data_path / 'statistics' 87 | map_dict = get_map_dict(species_data_path, tissue) 88 | 89 | gene_statistics_path = statistics_path / (tissue + '_genes.txt') # train+test gene 90 | cell_statistics_path = statistics_path / (tissue + '_cell_type.txt') # train labels 91 | 92 | # generate gene statistics file 93 | id2gene = get_id_2_gene(gene_statistics_path, species_data_path, tissue, params.train_dir) 94 | # generate cell label statistics file 95 | id2label = get_id_2_label(cell_statistics_path, species_data_path, tissue, params.train_dir) 96 | 97 | train_num, test_num = 0, 0 98 | # prepare unified genes 99 | gene2id = {gene: idx for idx, gene in enumerate(id2gene)} 100 | num_genes = len(id2gene) 101 | # prepare unified labels 102 | num_labels = len(id2label) 103 | label2id = {label: idx for idx, label in enumerate(id2label)} 104 | print(f"totally {num_genes} genes, {num_labels} labels.") 105 | 106 | train_labels = [] 107 | test_label_dict = dict() # test label dict 108 | test_index_dict = dict() # test-num: [begin-index, end-index] 109 | test_cell_id_dict = dict() # test-num: ['c1', 'c2'...] 110 | # TODO 111 | matrices = [] 112 | 113 | for num in train + test: 114 | start = time() 115 | if num in train: 116 | data_path = species_data_path / (params.train_dir + f'/{params.species}_{tissue}{num}_data.csv') 117 | type_path = species_data_path / (params.train_dir + f'/{params.species}_{tissue}{num}_celltype.csv') 118 | else: 119 | data_path = species_data_path / (params.test_dir + f'/{params.species}_{tissue}{num}_data.csv') 120 | type_path = species_data_path / (params.test_dir + f'/{params.species}_{tissue}{num}_celltype.csv') 121 | 122 | # load celltype file then update labels accordingly 123 | cell2type = pd.read_csv(type_path, index_col=0) 124 | cell2type.columns = ['cell', 'type'] 125 | cell2type['type'] = cell2type['type'].map(str.strip) 126 | if num in train: 127 | cell2type['id'] = cell2type['type'].map(label2id) 128 | assert not cell2type['id'].isnull().any(), 'something wrong in celltype file.' 129 | train_labels += cell2type['id'].tolist() 130 | else: 131 | # test_labels += cell2type['type'].tolist() 132 | test_label_dict[num] = cell2type['type'].tolist() 133 | 134 | # load data file then update graph 135 | df = pd.read_csv(data_path, index_col=0) # (gene, cell) 136 | if num in test: 137 | test_cell_id_dict[num] = list(df.columns) 138 | df = df.transpose(copy=True) # (cell, gene) 139 | 140 | assert cell2type['cell'].tolist() == df.index.tolist() 141 | df = df.rename(columns=gene2id) 142 | # filter out useless columns if exists (when using gene intersection) 143 | col = [c for c in df.columns if c in gene2id.values()] 144 | df = df[col] 145 | print(f'Nonzero Ratio: {df.fillna(0).astype(bool).sum().sum() / df.size * 100:.2f}%') 146 | # maintain inter-datasets index for graph and RNA-seq values 147 | arr = df.to_numpy() 148 | row_idx, col_idx = np.nonzero(arr > params.threshold) # intra-dataset index 149 | non_zeros = arr[(row_idx, col_idx)] # non-zero values 150 | 151 | gene_idx = df.columns[col_idx].astype(int).tolist() # gene_index 152 | info_shape = (len(df), num_genes) 153 | info = csr_matrix((non_zeros, (row_idx, gene_idx)), shape=info_shape) 154 | matrices.append(info) 155 | 156 | if num in train: 157 | train_num += len(df) 158 | else: 159 | test_index_dict[num] = list(range(train_num + test_num, train_num + test_num + len(df))) 160 | test_num += len(df) 161 | print(f'Costs {time() - start:.3f} s in total.') 162 | train_labels = np.array(list(map(int, train_labels))) 163 | 164 | # 2. create features 165 | sparse_feat = vstack(matrices).toarray() # cell-wise (cell, gene) 166 | test_feat_dict = dict() 167 | # transpose to gene-wise 168 | gene_pca = PCA(dense_dim, random_state=random_seed).fit(sparse_feat[:train_num].T) 169 | gene_feat = gene_pca.transform(sparse_feat[:train_num].T) 170 | gene_evr = sum(gene_pca.explained_variance_ratio_) * 100 171 | print(f'[PCA] Gene EVR: {gene_evr:.2f} %.') 172 | 173 | # do normalization 174 | sparse_feat = sparse_feat / (np.sum(sparse_feat, axis=1, keepdims=True) + 1e-6) 175 | # use weighted gene_feat as cell_feat 176 | cell_feat = sparse_feat.dot(gene_feat) # [total_cell_num, d] 177 | train_cell_feat = cell_feat[:train_num] 178 | 179 | for num in test_label_dict.keys(): 180 | test_feat_dict[num] = cell_feat[test_index_dict[num]] 181 | 182 | return num_labels, train_labels, train_cell_feat, map_dict, np.array(id2label, dtype=np.str), \ 183 | test_label_dict, test_feat_dict, test_cell_id_dict 184 | 185 | 186 | class Runner: 187 | def __init__(self, args): 188 | self.args = args 189 | self.prj_path = Path(__file__).parent.resolve().parent.resolve() 190 | self.num_labels, self.train_labels, self.train_cell_feat, self.map_dict, self.id2label, \ 191 | self.test_label_dict, self.test_feat_dict, self.test_cell_id_dict = load_data(args) 192 | self.model = self.fit() 193 | 194 | def fit(self): 195 | model = SVC(random_state=self.args.random_seed, probability=True). \ 196 | fit(self.train_cell_feat, self.train_labels) 197 | return model 198 | 199 | def evaluate(self): 200 | for num in self.args.test_dataset: 201 | score = self.model.predict_proba(self.test_feat_dict[num]) # [cell, class-num] 202 | pred_labels = [] 203 | unsure_num, correct = 0, 0 204 | for pred, t_label in zip(score, self.test_label_dict[num]): 205 | pred_label = self.id2label[pred.argmax().item()] 206 | if pred_label in self.map_dict[num][t_label]: 207 | correct += 1 208 | pred_labels.append(pred_label) 209 | 210 | acc = correct / score.shape[0] 211 | print(f'SVM-{self.args.species}-{self.args.tissue}-{num}-ACC: {acc:.5f}') 212 | self.save(num, pred_labels) 213 | 214 | def save(self, num, pred): 215 | label_map = pd.read_excel(self.prj_path / 'data' / 'celltype2subtype.xlsx', 216 | sheet_name=self.args.species, header=0, 217 | names=['species', 'old_type', 'new_type', 'new_subtype']) 218 | 219 | save_path = self.prj_path / self.args.save_dir 220 | if not save_path.exists(): 221 | save_path.mkdir() 222 | 223 | label_map = label_map.fillna('N/A', inplace=False) 224 | oldtype2newtype = {} 225 | oldtype2newsubtype = {} 226 | for _, old_type, new_type, new_subtype in label_map.itertuples(index=False): 227 | oldtype2newtype[old_type] = new_type 228 | oldtype2newsubtype[old_type] = new_subtype 229 | if not os.path.exists(self.args.save_dir): 230 | os.mkdir(self.args.save_dir) 231 | 232 | df = pd.DataFrame({ 233 | 'index': self.test_cell_id_dict[num], 234 | 'original label': self.test_label_dict[num], 235 | 'cell type': [oldtype2newtype.get(p, p) for p in pred], 236 | 'cell subtype': [oldtype2newsubtype.get(p, p) for p in pred] 237 | }) 238 | df.to_csv( 239 | save_path / ('SVM_' + self.args.species + f"_{self.args.tissue}_{num}.csv"), 240 | index=False) 241 | print(f"output has been stored in {self.args.species}_{self.args.tissue}_{num}.csv") 242 | 243 | 244 | def arg_parse(): 245 | parser = argparse.ArgumentParser() 246 | parser.add_argument("--random_seed", type=int, default=10086) 247 | parser.add_argument("--train_dataset", nargs="+", required=True, type=int, 248 | help="list of dataset id") 249 | parser.add_argument("--test_dataset", nargs="+", required=True, type=int, 250 | help="list of dataset id") 251 | parser.add_argument("--species", default='mouse', type=str) 252 | parser.add_argument("--tissue", required=True, type=str) 253 | parser.add_argument("--train_dir", type=str, default='train') 254 | parser.add_argument("--test_dir", type=str, default='test') 255 | 256 | params = parser.parse_args() 257 | params.save_dir = 'result' 258 | params.dense_dim = 400 259 | params.threshold = 0 260 | return params 261 | 262 | 263 | if __name__ == '__main__': 264 | params = arg_parse() 265 | 266 | runner = Runner(params) 267 | runner.evaluate() 268 | -------------------------------------------------------------------------------- /SVM/SVM_res_human.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/SVM/SVM_res_human.rds -------------------------------------------------------------------------------- /SVM/SVM_res_mouse.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/SVM/SVM_res_mouse.rds -------------------------------------------------------------------------------- /SingleR/SingleR.R: -------------------------------------------------------------------------------- 1 | library(SingleR) 2 | 3 | # Single-cell transcriptomics and cell type information are both curated from literature and pre-processed generating ndata and the corresponding celltype objects. 4 | # ndata represents the normolized dgCMatrix object using Seurat. Each row represents a gene (gene symbol) and each column represents a cell (cell barcode). 5 | # celltype represents the data.frame object containg two columns, namely cell barcode and cell type. 6 | 7 | # ref_ndata represents the normolized dgCMatrix object using Seurat from HCL or MCA. Each row represents a gene (gene symbol) and each column represents a cell (cell barcode). 8 | # ref_celltype represents the data.frame object containg two columns, namely cell barcode and cell type. 9 | 10 | pre_res<- SingleR(test = as.matrix(ndata),ref = as.matrix(ref_ndata),labels = ref_celltype$celltype,method = 'single') 11 | celltype$SingleR<- pre_res$labels -------------------------------------------------------------------------------- /SingleR/SingleR_res_human.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/SingleR/SingleR_res_human.rds -------------------------------------------------------------------------------- /SingleR/SingleR_res_mouse.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/SingleR/SingleR_res_mouse.rds -------------------------------------------------------------------------------- /scDeepSort/scDeepSort_res_human.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/scDeepSort/scDeepSort_res_human.rds -------------------------------------------------------------------------------- /scDeepSort/scDeepSort_res_mouse.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/scDeepSort/scDeepSort_res_mouse.rds -------------------------------------------------------------------------------- /scID/scID.R: -------------------------------------------------------------------------------- 1 | library(scID) 2 | 3 | # Single-cell transcriptomics and cell type information are both curated from literature and pre-processed generating ndata and the corresponding celltype objects. 4 | # ndata represents the normolized dgCMatrix object using Seurat. Each row represents a gene (gene symbol) and each column represents a cell (cell barcode). 5 | # celltype represents the data.frame object containg two columns, namely cell barcode and cell type. 6 | 7 | # ref_ndata represents the normolized dgCMatrix object using Seurat from HCL or MCA. Each row represents a gene (gene symbol) and each column represents a cell (cell barcode). 8 | # ref_celltype represents the data.frame object containg two columns, namely cell barcode and cell type. 9 | 10 | ref_cluster<- unique(ref_celltype$celltype) 11 | ref_cluster<- data.frame(cluster = 1:length(ref_cluster),celltype = ref_cluster,stringsAsFactors = F) 12 | ref_celltype$cluster<- 'NO' 13 | for (i in 1:nrow(ref_cluster)) { 14 | ref_celltype[ref_celltype$celltype == ref_cluster$celltype[i],]$cluster<- ref_cluster$cluster[i] 15 | } 16 | 17 | ref_Seurat<- CreateSeuratObject(counts = ref_ndata) 18 | Idents(ref_Seurat) <- ref_celltype$cluster 19 | ref_markers<- FindAllMarkers(object = ref_Seurat,test.use = 'MAST',only.pos = F,logfc.threshold = 0.5) 20 | # train and predict 21 | scID_output <- scid_multiclass(target_gem = as.matrix(ndata), 22 | reference_gem = as.matrix(ref_ndata), 23 | reference_clusters = Idents(ref_Seurat), 24 | markers = ref_markers) 25 | 26 | celltype$scID<- scID_output$labels 27 | 28 | 29 | -------------------------------------------------------------------------------- /scID/scID_res_human.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/scID/scID_res_human.rds -------------------------------------------------------------------------------- /scID/scID_res_mouse.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/scID/scID_res_mouse.rds -------------------------------------------------------------------------------- /scMap/scMap.R: -------------------------------------------------------------------------------- 1 | library(SingleCellExperiment) 2 | library(scmap) 3 | 4 | # Single-cell transcriptomics and cell type information are both curated from literature and pre-processed generating ndata and the corresponding celltype objects. 5 | # ndata represents the normolized dgCMatrix object using Seurat. Each row represents a gene (gene symbol) and each column represents a cell (cell barcode). 6 | # celltype represents the data.frame object containg two columns, namely cell barcode and cell type. 7 | 8 | # ref_ndata represents the normolized dgCMatrix object using Seurat from HCL or MCA. Each row represents a gene (gene symbol) and each column represents a cell (cell barcode). 9 | # ref_celltype represents the data.frame object containg two columns, namely cell barcode and cell type. 10 | 11 | # Create ref_ndata sce object 12 | ref_celltype<- data.frame(cell_type1 = ref_celltype$celltype,stringsAsFactors = F) 13 | rownames(ref_celltype)<- colnames(ref_ndata) 14 | ref_ndata_sce<- SingleCellExperiment(assays = list(normcounts = as.matrix(ref_ndata)),colData = ref_celltype) 15 | logcounts(ref_ndata_sce) <- normcounts(ref_ndata_sce) 16 | rowData(ref_ndata_sce)$feature_symbol <- rownames(ref_ndata_sce) 17 | isSpike(ref_ndata_sce, "ERCC") <- grepl("^ERCC-", rownames(ref_ndata_sce)) 18 | ref_ndata_sce <- ref_ndata_sce[!duplicated(rownames(ref_ndata_sce)), ] 19 | ref_ndata_sce <- selectFeatures(ref_ndata_sce, suppress_plot = F) 20 | 21 | # Create test data sce object 22 | test_ndata_sce<- SingleCellExperiment(assays = list(normcounts = as.matrix(ndata))) 23 | logcounts(test_ndata_sce) <- normcounts(test_ndata_sce) 24 | rowData(test_ndata_sce)$feature_symbol <- rownames(test_ndata_sce) 25 | isSpike(test_ndata_sce, "ERCC") <- grepl("^ERCC-", rownames(test_ndata_sce)) 26 | test_ndata_sce <- test_ndata_sce[!duplicated(rownames(test_ndata_sce)), ] 27 | test_ndata_sce <- selectFeatures(test_ndata_sce, suppress_plot = FALSE) 28 | 29 | # Annotating cell-based 30 | ref_ndata_sce <- indexCell(ref_ndata_sce) 31 | scmapCell_results <- scmapCell( 32 | test_ndata_sce, 33 | list( 34 | scmap = metadata(ref_ndata_sce)$scmap_cell_index 35 | ) 36 | ) 37 | scmapCell_clusters <- scmapCell2Cluster( 38 | scmapCell_results, 39 | list( 40 | as.character(colData(ref_ndata_sce)$cell_type1) 41 | ) 42 | ) 43 | celltype$scmap_cell<- scmapCell_clusters$scmap_cluster_labs 44 | 45 | 46 | # Annotating cluster-based 47 | ref_ndata_sce <- indexCluster(ref_ndata_sce) 48 | scmapCluster_results <- scmapCluster( 49 | test_ndata_sce, 50 | list( 51 | scmap = metadata(ref_ndata_sce)$scmap_cluster_index 52 | ) 53 | ) 54 | celltype$scmap_cluster<- scmapCluster_results$scmap_cluster_labs 55 | -------------------------------------------------------------------------------- /scMap/scmap_cell_res_human.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/scMap/scmap_cell_res_human.rds -------------------------------------------------------------------------------- /scMap/scmap_cell_res_mouse.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/scMap/scmap_cell_res_mouse.rds -------------------------------------------------------------------------------- /scMap/scmap_cluster_res_human.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/scMap/scmap_cluster_res_human.rds -------------------------------------------------------------------------------- /scMap/scmap_cluster_res_mouse.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/scMap/scmap_cluster_res_mouse.rds -------------------------------------------------------------------------------- /scPred/scPred.R: -------------------------------------------------------------------------------- 1 | library(scPred) 2 | library(methods) 3 | # Single-cell transcriptomics and cell type information are both curated from literature and pre-processed generating ndata and the corresponding celltype objects. 4 | # ndata represents the normolized dgCMatrix object using Seurat. Each row represents a gene (gene symbol) and each column represents a cell (cell barcode). 5 | # celltype represents the data.frame object containg two columns, namely cell barcode and cell type. 6 | 7 | # ref_ndata represents the normolized dgCMatrix object using Seurat from HCL or MCA. Each row represents a gene (gene symbol) and each column represents a cell (cell barcode). 8 | # ref_celltype represents the data.frame object containg two columns, namely cell barcode and cell type. 9 | 10 | getFeatureSpace_debug <- function(object, pVar, varLim = 0.01, correction = "fdr", sig = 0.05){ 11 | 12 | 13 | # Validations ------------------------------------------------------------- 14 | 15 | if(!is(object, "scPred") & !is(object, "Seurat")){ 16 | stop("Invalid class for object: must be 'scPred' or 'Seurat'") 17 | } 18 | 19 | if(!any(correction %in% stats::p.adjust.methods)){ 20 | stop("Invalid multiple testing correction method. See ?p.adjust function") 21 | } 22 | 23 | if(is(object, "scPred")){ 24 | classes <- metadata(object)[[pVar]] 25 | }else{ 26 | classes <- object[[pVar, drop = TRUE]] 27 | } 28 | 29 | if(is.null(classes)){ 30 | stop("Prediction variable is not stored in metadata slot") 31 | } 32 | 33 | if(!is.factor(classes)){ 34 | message("Transforming prediction variable to factor object...") 35 | classes <- as.factor(classes) 36 | } 37 | 38 | # Filter principal components by variance --------------------------------- 39 | 40 | if(is(object, "scPred")){ # scPred object 41 | 42 | # Get PCA 43 | i <- object@expVar > varLim 44 | pca <- getPCA(object)[,i] 45 | 46 | # Get variance explained 47 | expVar <- object@expVar 48 | 49 | }else{ # seurat object 50 | 51 | # Check if a PCA has been computed 52 | if(!("pca" %in% names(object@reductions))){ 53 | stop("No PCA has been computet yet. See RunPCA() function") 54 | } 55 | 56 | # Check if available was normalized 57 | 58 | assay <- DefaultAssay(object) 59 | cellEmbeddings <- Embeddings(object) 60 | 61 | 62 | # Subset PCA 63 | expVar <- Stdev(object)**2/sum(Stdev(object)**2) 64 | names(expVar) <- colnames(Embeddings(object)) 65 | i <- expVar > varLim 66 | 67 | # Create scPred object 68 | pca <- Embeddings(object)[,i] 69 | 70 | } 71 | 72 | uniqueClasses <- unique(classes) 73 | isValidName <- uniqueClasses == make.names(uniqueClasses) 74 | 75 | if(!all(isValidName)){ 76 | 77 | invalidClasses <- paste0(uniqueClasses[!isValidName], collapse = "\n") 78 | message("Not all the classes are valid R variable names\n") 79 | message("The following classes are renamed: \n", invalidClasses) 80 | classes <- make.names(classes) 81 | classes <- factor(classes, levels = unique(classes)) 82 | newPvar <- paste0(pVar, ".valid") 83 | if(is(object, "scPred")){ 84 | object@metadata[[newPvar]] <- classes 85 | }else{ 86 | object@meta.data[[newPvar]] <- classes 87 | } 88 | message("\nSee new classes in '", pVar, ".valid' column in metadata:") 89 | message(paste0(levels(classes)[!isValidName], collapse = "\n"), "\n") 90 | pVar <- newPvar 91 | } 92 | 93 | 94 | 95 | 96 | # Select informative principal components 97 | # If only 2 classes are present in prediction variable, train one model for the positive class 98 | # The positive class will be the first level of the factor variable 99 | 100 | if(length(levels(classes)) == 2){ 101 | 102 | message("First factor level in '", pVar, "' metadata column considered as positive class") 103 | res <- .getFeatures(levels(classes)[1], expVar, classes, pca, correction, sig) 104 | res <- list(res) 105 | names(res) <- levels(classes)[1] 106 | 107 | }else{ 108 | 109 | res <- pblapply(levels(classes), .getFeatures, expVar, classes, pca, correction, sig) 110 | names(res) <- levels(classes) 111 | 112 | } 113 | 114 | 115 | nFeatures <- unlist(lapply(res, nrow)) 116 | 117 | noFeatures <- nFeatures == 0 118 | 119 | if(any(noFeatures)){ 120 | 121 | warning("\nWarning: No features were found for classes:\n", 122 | paste0(names(res)[noFeatures], collapse = "\n"), "\n") 123 | 124 | res1<- list() 125 | for (j in 1:length(res)) { 126 | d1<- res[[j]] 127 | if (nrow(d1) > 0) { 128 | res1[names(res)[j]]<- res[j] 129 | } 130 | } 131 | res<- res1 132 | } 133 | 134 | message("\nDONE!") 135 | 136 | 137 | # Assign feature space to `features` slot 138 | if(inherits(object, "Seurat")){ 139 | 140 | # Create scPred object 141 | scPredObject <- list(expVar = expVar, 142 | features = res, 143 | pVar = pVar, 144 | pseudo = FALSE) 145 | 146 | object@misc <- list(scPred = scPredObject) 147 | 148 | }else{ 149 | 150 | 151 | object@features <- res 152 | object@pVar <- pVar 153 | } 154 | 155 | object 156 | 157 | } 158 | 159 | scPredict_debug <- function(object, newData = NULL, threshold = 0.9, 160 | returnProj = TRUE, returnData = FALSE, informative = TRUE, 161 | useProj = FALSE){ 162 | 163 | # Function validations ---------------------------------------------------- 164 | 165 | # Validate if provided object is an scPred object 166 | if(!is(object, "scPred")){ 167 | stop("'object' must be of class 'scPred'") 168 | } 169 | 170 | # Validate if scPred models have been trained already 171 | if(!length(object@train)){ 172 | stop("No models have been trained!") 173 | } 174 | 175 | # Predictions are only possible if new data is provided. The new data can be a gene expression 176 | # matrix or a loading projection that has been computed independently. 177 | # Validate if new data is provided. If only a projection is found in the @projection slot, 178 | # this one is used as the prediction/test data 179 | if(is.null(newData) & (nrow(object@projection) == 0)){ # Neither newData nor projection 180 | 181 | stop("No newData or pre-computed projection") 182 | 183 | }else if(is.null(newData) & nrow(object@projection)){ # No newData and projection 184 | 185 | message("Using projection stored in object as prediction set") 186 | useProj <- TRUE 187 | 188 | }else if(!is.null(newData) & nrow(object@projection)){ # NewData and projection 189 | 190 | if (!(is(newData, "matrix") | is(newData, "Matrix"))){ 191 | stop("'newData' object must be a matrix or seurat object") 192 | } 193 | message("newData provided and projection stored in scPred object. Set 'useProj = TRUE' to override default projection execution") 194 | } 195 | 196 | # Evaluate if there are identified features stored in the scPred object 197 | if(!length(object@features)){ 198 | stop("No informative principal components have been obtained yet.\nSee getInformativePCs() function") 199 | } 200 | 201 | # Convert newData to sparse Matrix object 202 | if(is(newData, "matrix")){ 203 | newData <- Matrix(newData) 204 | } 205 | 206 | # Data projection --------------------------------------------------------- 207 | 208 | # By default, projection of training loadings is automatically done. This option can be override 209 | # with the `useProj` argument to use an independent projection stored directly in the object. 210 | if(!useProj){ 211 | projection <- projectNewData(object = object, 212 | newData = newData, 213 | informative = informative, 214 | seurat = if(!is.null(object@svd$seurat)){TRUE}else{FALSE}) 215 | }else{ 216 | projection <- object@projection 217 | } 218 | # Get cell classes used for training 219 | classes <- names(object@features) 220 | # Cell class prediction --------------------------------------------------- 221 | # For all cell classes which a training models has been trained for, get 222 | # the prediction probability for each cell in the `projection` object 223 | message("Predicting cell types") 224 | res <- pbapply::pblapply(classes, .predictClass, object, projection) 225 | names(res) <- levels(classes) 226 | # Exclude NA cekk type 227 | res_nrow <- NULL 228 | for (i in 1:length(res)) { 229 | res_nrow1 <- nrow(res[[i]]) 230 | res_nrow <- c(res_nrow,res_nrow1) 231 | if (res_nrow1 != nrow(projection)) { 232 | d1 <- data.frame(res_nrow1 = rep(0,nrow(projection))) 233 | colnames(d1)<- colnames(res[[i]]) 234 | res[[i]]<- d1 235 | } 236 | } 237 | res_nrow1<- which(res_nrow != nrow(projection)) 238 | # Gather results in a dataframe 239 | res <- as.data.frame(res) 240 | if (length(res_nrow1) > 0) { 241 | res <- res[,-res_nrow1] 242 | } 243 | row.names(res) <- rownames(projection) 244 | if(length(classes) == 1){ 245 | # If only one model was trained (positive and negative classes present in prediction 246 | # variable only), get the probability for the negative class using the complement rule 247 | # P(negative_class) = 1 - positive_class 248 | allClasses <- unique(object@metadata[[object@pVar]]) 249 | positiveClass <- classes 250 | negativeClass <- as.character(allClasses[!allClasses %in% classes]) 251 | res[[negativeClass]] <- 1 - res[[positiveClass]] 252 | # Assign cells according to their associated probabilities 253 | res$predClass <- ifelse(res[,1] > threshold, positiveClass, 254 | ifelse(res[,2] > threshold, negativeClass, "unassigned")) %>% 255 | as.factor() 256 | # Save results to `@predictions` slot 257 | object@predictions <- res 258 | }else{ 259 | # If more than one model was trained (there are 3 classes or more in the prediction variable), 260 | # obtain the maximum probability for each cell and assign the respective class to that cell. 261 | i <- apply(res, 1, which.max) 262 | prob <- c() 263 | for(j in seq_len(nrow(res))){ 264 | prob[j] <- res[j,i[j]] 265 | } 266 | predictions <- data.frame(res, probability = prob, prePrediction = names(res)[i]) 267 | rownames(predictions) <- rownames(projection) 268 | predictions %>% 269 | tibble::rownames_to_column("id") %>% 270 | dplyr::mutate(predClass = ifelse(probability > threshold, as.character(prePrediction), "unassigned")) %>% 271 | dplyr::select(-probability, -prePrediction) %>% 272 | tibble::column_to_rownames("id") -> finalPrediction 273 | 274 | # Save results to `@predictions` slot 275 | object@predictions <- finalPrediction 276 | } 277 | if(returnProj & !useProj){ 278 | object@projection <- projection 279 | } 280 | if(returnData & !is.null(newData)){ 281 | if(object@pseudo){ 282 | object@predData <- log2(newData + 1) 283 | }else{ 284 | object@predData <- newData 285 | } 286 | } 287 | return(object) 288 | } 289 | 290 | 291 | 292 | # Eigendecomposition 293 | scp <- eigenDecompose(as.matrix(ref_ndata),pseudo = F) 294 | metadata(scp) <- ref_celltype 295 | # Feature selection 296 | scp <- getFeatureSpace_debug(scp, pVar = "celltype") 297 | # Model training 298 | scp <- trainModel(scp) 299 | # Prediction step 300 | scp <- scPredict_debug(scp, newData = as.matrix(ndata)) 301 | 302 | scp_pred<- getPredictions(scp) 303 | celltype$scPred<- scp_pred$predClass 304 | 305 | -------------------------------------------------------------------------------- /scPred/scPred_res_human.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/scPred/scPred_res_human.rds -------------------------------------------------------------------------------- /scPred/scPred_res_mouse.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/scPred/scPred_res_mouse.rds -------------------------------------------------------------------------------- /singleCellNet/singleCellNet.R: -------------------------------------------------------------------------------- 1 | library(singleCellNet) 2 | # Single-cell transcriptomics and cell type information are both curated from literature and pre-processed generating ndata and the corresponding celltype objects. 3 | # ndata represents the normolized dgCMatrix object using Seurat. Each row represents a gene (gene symbol) and each column represents a cell (cell barcode). 4 | # celltype represents the data.frame object containg two columns, namely cell barcode and cell type. 5 | 6 | # ref_ndata represents the normolized dgCMatrix object using Seurat from HCL or MCA. Each row represents a gene (gene symbol) and each column represents a cell (cell barcode). 7 | # ref_celltype represents the data.frame object containg two columns, namely cell barcode and cell type. 8 | 9 | 10 | colnames(ref_celltype)<- c('cell','ann') 11 | colnames(celltype)<- c('cell','ann') 12 | ref_ndata<- ref_ndata[rownames(ref_ndata) %in% rownames(ndata),] 13 | #train 14 | class_info<- scn_train(stTrain = ref_celltype, 15 | expTrain = ref_ndata, 16 | dLevel = "ann", 17 | colName_samp = "cell") 18 | # Predict 19 | crParkall<- scn_predict(class_info[['cnProc']], ndata, nrand = 2) 20 | 21 | stPark <- get_cate(classRes = crParkall, 22 | sampTab = celltype, dLevel = "ann", sid = "cell", 23 | nrand = 50) -------------------------------------------------------------------------------- /singleCellNet/singleCellNet_res_human.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/singleCellNet/singleCellNet_res_human.rds -------------------------------------------------------------------------------- /singleCellNet/singleCellNet_res_mouse.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUFanLab/scDeepSort_performance_comparison/10fbedf71efe10453f578f5174fab645faeb47e5/singleCellNet/singleCellNet_res_mouse.rds --------------------------------------------------------------------------------