├── .Rbuildignore ├── .gitattributes ├── .gitignore ├── DESCRIPTION ├── LICENSE ├── NAMESPACE ├── R ├── ChordDiagram.R ├── Cox.R ├── Dotplot.R ├── Enrich.R ├── Favorability.R ├── Fisher.R ├── Network.R ├── Pairwise.R ├── Permutation.R ├── Preprocess.R ├── data.R └── sysdata.rda ├── README.md ├── TimiGP.Rproj ├── assets └── images │ ├── Fig1A.png │ ├── Fig3A.png │ ├── Fig3B.png │ ├── Fig3C.png │ ├── Fig3D.png │ ├── Fig3x.png │ ├── application.png │ ├── framework.png │ └── rationale.png ├── data ├── Bindea2013c_COX_MP_SKCM06.rda ├── Bindea2013c_enrich.rda ├── CellType_Bindea2013_cancer.rda ├── CellType_Charoentong2017_Bindea2013_Xu2018_Immune.rda ├── CellType_Newman2015_LM22.rda ├── CellType_TNBC_aPDL1.rda ├── CellType_Tirosh2016_melanoma_TME.rda ├── CellType_Zheng2021_Tcell.rda ├── Immune_Marker_n1293.rda ├── SKCM06info.rda ├── SKCM06rna.rda ├── TNBCaPD1info.rda └── TNBCaPD1rna.rda ├── example ├── example01_Bindea2013_Cancer.R ├── example02_Charoentong2017_Bindea2013_Xu2018_Immune.R ├── example03_Newman2015_LM22.R ├── example04_Tirosh2016_melanoma_TME.R ├── example05_Zheng2021_Tcell.R ├── example06_Bindea2013_Cancer_continuous_pair.R └── example07_customized_TNBC_Response.R ├── inst └── extdata │ ├── Bindea2013_tableS1_immune.txt │ ├── CellType_summary.csv │ ├── Charoentong2017_tableS6_Immune.txt │ ├── Newman2015_TableS1.txt │ ├── Tirosh2016_tableS3_melanoma.txt │ ├── Xu2018_Signature.txt │ ├── Zheng2021_tableS2_Tcell.txt │ ├── build_CellType_Bindea2013_cancer.R │ ├── build_CellType_Charoentong2017_Bindea2013_Xu2018_Immune.R │ ├── build_CellType_Newman2015_LM22.R │ ├── build_CellType_Tirosh2016_melanoma_TME.R │ ├── build_CellType_Zheng2021_Tcell.R │ ├── build_Immune_Marker_n1293.R │ ├── build_SKCM06_RNA_info.R │ ├── build_TNBCaPD1_RNA_info.R │ └── build_sysdata.R └── man ├── Bindea2013c_COX_MP_SKCM06.Rd ├── Bindea2013c_enrich.Rd ├── CellType_Bindea2013_cancer.Rd ├── CellType_Charoentong2017_Bindea2013_Xu2018_Immune.Rd ├── CellType_Newman2015_LM22.Rd ├── CellType_TNBC_aPDL1.Rd ├── CellType_Tirosh2016_melanoma_TME.Rd ├── CellType_Zheng2021_Tcell.Rd ├── Immune_Marker_n1293.Rd ├── SKCM06info.Rd ├── SKCM06rna.Rd ├── TNBCaPD1info.Rd ├── TNBCaPD1rna.Rd ├── TimiBG.Rd ├── TimiCOX.Rd ├── TimiCellChord.Rd ├── TimiCellNetwork.Rd ├── TimiCellPair.Rd ├── TimiCheckEvent.Rd ├── TimiDotplot.Rd ├── TimiEnrich.Rd ├── TimiFS.Rd ├── TimiFSBar.Rd ├── TimiFisher.Rd ├── TimiGeneChord.Rd ├── TimiGeneNetwork.Rd ├── TimiGenePair.Rd ├── TimiPermFDR.Rd └── TimiPrePropress.Rd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | notebook* 4 | assets* 5 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | notebook 5 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: TimiGP 2 | Type: Package 3 | Title: TimiGP: Inferring cell-cell interactions and clinical associations in the tumor immune microenvironment through gene pairs 4 | Version: 1.3.0 5 | RoxygenNote: 7.2.3 6 | Encoding: UTF-8 7 | Depends: 8 | R (>= 4.0.0) 9 | Imports: 10 | circlize, 11 | doParallel, 12 | dplyr, 13 | foreach, 14 | ggplot2, 15 | RColorBrewer, 16 | survival 17 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(TimiBG) 4 | export(TimiCOX) 5 | export(TimiCellChord) 6 | export(TimiCellNetwork) 7 | export(TimiCellPair) 8 | export(TimiCheckEvent) 9 | export(TimiDotplot) 10 | export(TimiEnrich) 11 | export(TimiFS) 12 | export(TimiFSBar) 13 | export(TimiFisher) 14 | export(TimiGeneChord) 15 | export(TimiGeneNetwork) 16 | export(TimiGenePair) 17 | export(TimiPermFDR) 18 | export(TimiPrePropress) 19 | import(RColorBrewer) 20 | import(circlize) 21 | import(doParallel) 22 | import(dplyr) 23 | import(foreach) 24 | import(ggplot2) 25 | import(survival) 26 | importFrom(survival,Surv) 27 | -------------------------------------------------------------------------------- /R/Cox.R: -------------------------------------------------------------------------------- 1 | ##' Find marker pairs associated with favorable prognosis 2 | ##' 3 | ##' Perform univariate cox regression that fits each marker pair as a variable. 4 | ##' If a Pair A_B associated with poor prognosis(HR > 1), even not significant, 5 | ##' it will be changed to B_A and reverse its value in the matrix of pair 6 | ##' 7 | ##' @param mps a matrix of Marker Pair Score 8 | ##' @param info a data.frame in which the 1st column is event 9 | ##' and the 2nd column is days-to-event. 10 | ##' @param p.adj p.adjust.methods. 11 | ##' One of "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none". 12 | ##' The default value is "BH". 13 | ##' @param parallel a logical value. If TRUE, enable parallel computing. 14 | ##' The default value if FALSE 15 | ##' @param core a numeric value shows the number of cores for parallel execution. 16 | ##' The default value is 1. 17 | ##' @return A list of two results: 18 | ##' 1. Result of cox regression(cox_res) 19 | ##' (HR: Hazard.Ratio,PV: P-Value,QV: Adjust P-value). 20 | ##' 2. modified marker pair score(mps) 21 | ##' @import survival 22 | ##' @import dplyr 23 | ##' @import foreach 24 | ##' @import doParallel 25 | ##' @export 26 | ##' @examples 27 | ##' \dontrun{ 28 | ##' data("SKCM06info") 29 | ##' data("SKCM06rna") 30 | ##' data("Immune_Marker_n1293") 31 | ##' info <- TimiCheckEvent(SKCM06info) 32 | ##' rna <- TimiPrePropress(gene = Immune_Marker_n1293,rna = SKCM06rna,cohort = rownames(info)) 33 | ##' mps <- TimiGenePair(rna) 34 | ##' dim(mps) 35 | ##' # TimiCOX 36 | ##' res <- TimiCOX(mps = mps,info = info,p.adj = "BH") 37 | ##' mps <- res[["mps"]] 38 | ##' cox_res <- res[["cox_res"]] 39 | ##' } 40 | ##' @author Chenyang Skylar Li 41 | 42 | TimiCOX <- function(mps = NULL, 43 | info = NULL, 44 | p.adj = "BH", 45 | parallel = FALSE, 46 | core = 1){ 47 | # examine required parameters------------------------------------------------- 48 | if (is.null(mps)){ 49 | stop('The parameter "mps" is required. ') 50 | } 51 | 52 | if (is.null(info)){ 53 | stop('The parameter "info" is required. ') 54 | } 55 | 56 | if (is.null(p.adj)){ 57 | stop('The parameter "p.adj" is required. Please choose one of c("holm", "hochberg", "hommel", "bonferroni","BH", "BY","fdr", "none")') 58 | } 59 | 60 | 61 | if (all(colnames(mps) == rownames(info)) == FALSE){ 62 | comSam <- intersect(row.names(info), colnames(mps)) 63 | if (length(comSam) > 0) { 64 | mps <- mps[,comSam] 65 | info <- info[comSam,] 66 | } else { 67 | stop('Samples are different between Gene pair score and clinical info') 68 | } 69 | if (all(colnames(mps) == rownames(info)) == FALSE) { 70 | stop('Samples are different between Gene pair score and clinical info') 71 | } 72 | 73 | } 74 | 75 | # cox function --------------------------------------------------------------- 76 | MyCox <- function(mytag = NULL, 77 | info = NULL, 78 | logic = T # T: 0 or 1; F: numeric 79 | ){ 80 | if (logic == T){ 81 | mytag <- as.factor(mytag) 82 | 83 | } else if (logic == F) { 84 | mytag <- as.numeric(mytag) 85 | } 86 | 87 | tmp <- as.data.frame(cbind(info, mytag)) 88 | test <- coxph(Surv(as.numeric(info[,2]), 89 | as.numeric( info[,1]))~mytag, 90 | tmp) 91 | test <- summary(test) 92 | res <- c( test$conf.int[1], test$coefficients[5]) 93 | names(res) <- c("HR","PV") 94 | return (res) 95 | } 96 | # perform cox ---------------------------------------------------------------- 97 | # examine the mps is generated from logical relation or continuous relation 98 | 99 | if (parallel == F) { # No parallel, use apply 100 | message("------------- Calculating -------------") 101 | message("Please be patient. This step usually takes approximately 5 minutes.") 102 | message("The computation time may be increased if there are a larger number of cell type markers (e.g., > 1000 markers for > 30 mins).") 103 | message('To speed up, you can enable parallel computing by setting "parallel = T" and the number of cores (core).') 104 | if (is.logical(mps) == T) { 105 | 106 | # perform cox logical ------------------------------------------------------ 107 | cox_res <- apply(mps * 1, 1, function (x) 108 | MyCox(mytag = x,info = info, logic = T)) 109 | 110 | } else if (is.numeric(mps) == T) { 111 | # perform cox continuous --------------------------------------------------- 112 | cox_res <- apply(mps, 1, function (x) 113 | MyCox(mytag = x,info = info, logic = F)) 114 | 115 | } else { 116 | stop('The matrix are neither logical nor numeric values') 117 | } 118 | } else if (parallel == T) { # parallel, select core 119 | message("Enable parallel computing.") 120 | if (core == 1) { 121 | warning("Only 1 core specified. You may want to change core > 1") 122 | } 123 | 124 | message("------------- Calculating -------------") 125 | message("Please be patient.") 126 | message("The computation time may be increased if there are a larger number of cell type markers.") 127 | registerDoParallel(cores=core) 128 | 129 | if (is.logical(mps) == T) { 130 | 131 | # perform cox logical ------------------------------------------------------ 132 | cox_res <- foreach (i = 1:nrow(mps), .combine=cbind) %dopar% { 133 | MyCox(mytag = mps[i,]*1,info = info, logic = T) 134 | } 135 | 136 | } else if (is.numeric(mps) == T) { 137 | # perform cox continuous --------------------------------------------------- 138 | cox_res <- foreach (i = 1:nrow(mps), .combine=cbind) %dopar% { 139 | MyCox(mytag = mps[i,]*1,info = info, logic = F) 140 | } 141 | 142 | } else { 143 | stop('The matrix are neither logical nor numeric values') 144 | } 145 | 146 | } 147 | 148 | cox_res <- cox_res %>% 149 | t() %>% 150 | data.frame() %>% 151 | mutate(QV = p.adjust(PV, method=p.adj)) 152 | row.names(cox_res) <- row.names(mps) 153 | # change pair direction of cox result----------------------------------------- 154 | se <- which(cox_res$HR>1) 155 | message("The direction of ",length(se)," marker pairs were reversed") 156 | 157 | xx <- row.names(cox_res[se,]) 158 | xx <- unlist(strsplit(xx, "_")) 159 | xx1 <- xx[seq(1,length(xx),2)] 160 | xx2 <- xx[seq(2,length(xx),2)] 161 | xx <- paste(xx2, xx1, sep="_") 162 | 163 | cox_res$HR[se] <- 1/cox_res$HR[se] 164 | rownames(cox_res)[se] <- xx 165 | 166 | # change pair direction and reverse value of marker pair score---------------- 167 | rownames(mps)[se] <- xx 168 | 169 | if (is.logical(mps) == T) { 170 | mps[se,] <- !mps[se,] 171 | } else if (is.numeric(mps) == T) { 172 | mps[se,] <- -mps[se,] 173 | } else { 174 | stop('The matrix are neither logical nor numeric values') 175 | } 176 | 177 | cox_res <-cox_res[order(cox_res[,2]),] 178 | res <- list("mps" = mps,"cox_res" = cox_res) 179 | 180 | return(res) 181 | 182 | } 183 | 184 | 185 | -------------------------------------------------------------------------------- /R/Dotplot.R: -------------------------------------------------------------------------------- 1 | ##' Dotplot 2 | ##' 3 | ##' A dotplot shows the results of selected cell interaction enrichment. 4 | ##' The x-axis shows selected cell interactions. The y-axis shows Enrichment Ratio. 5 | ##' The color of dots represents FDR. 6 | ##' The size of dots represents the number of marker pairs 7 | ##' shared by query pairs and annotation pairs. 8 | ##' 9 | ##' @param resdata TimiGP enrichment result generated from TimiEnrich 10 | ##' @param select a numeric vector of selected cell interactions according to "Index" column in resdata. 11 | ##' Default selection is top 5 enrichment. 12 | ##' @param condition A value in one of 13 | ##' c("P.Value","Adjust.P.Value","Permutation.FDR"), 14 | ##' which is the column name of resdata and will be represented by color for the dot plot. 15 | ##' The default value is the "Adjust.P.Value". 16 | ##' @param cutoff The maximum value for the color bar. 17 | ##' The default value is 0.05, which is used for the default condition "Adjust.P.Value". 18 | ##' For other conditions, 0.01 is recommended for "P.Value", 19 | ##' and 0.2 is recommended for "Permutation.FDR". 20 | ##' @return Enrichment dotpot 21 | ##' @import ggplot2 22 | ##' @export 23 | ##' @examples 24 | ##' \dontrun{ 25 | ##' data("Bindea2013c_enrich") 26 | ##' res <- Bindea2013c_enrich 27 | ##' p1<-TimiDotplot(res) 28 | ##' p1 29 | ##' p2<-TimiDotplot(res,select = c(1:10)) 30 | ##' p2 31 | ##' 32 | ##' } 33 | ##' @author Chenyang Skylar Li 34 | 35 | TimiDotplot<- function(resdata = NULL, 36 | select = 1:5, 37 | condition = "Adjust.P.Value", 38 | cutoff = 0.05){ 39 | 40 | # Examine required parameters------------------------------------------------- 41 | if (is.null(resdata)){ 42 | stop('The parameter "resdata" is required.') 43 | } 44 | 45 | if (is.null(condition)){ 46 | stop('The parameter "condition" is required. Please choose one of c("P.Value","Adjust.P.Value","Permutation.FDR")') 47 | } else if(sum(condition %in% c("P.Value","Adjust.P.Value","Permutation.FDR")) !=1){ 48 | stop('Please choose one of c("P.Value","Adjust.P.Value","Permutation.FDR")') 49 | } else { 50 | message("The color for dotplot is ", condition) 51 | } 52 | 53 | if (is.null(cutoff)){ 54 | stop('The parameter "cutoff" is required. Please set it like 0.05, 0.01') 55 | } else { 56 | message("The color bar limits for dotplot is ", cutoff) 57 | } 58 | # plot 59 | resdata$Cell.Interaction <- factor(resdata$Cell.Interaction, 60 | levels=resdata$Cell.Interaction) 61 | se <- which(resdata$Index %in% select) 62 | max <- max(ceiling(resdata$Enrichment.Ratio[se]))+1 63 | p<- ggplot(resdata[se,] ) + 64 | geom_point( 65 | mapping = aes(x=Cell.Interaction, y=Enrichment.Ratio, 66 | color=get(condition), 67 | size=No.Shared.IMGP)) + 68 | scale_color_continuous(low="#9970ab", high="#5aae61", 69 | limits = c(0, cutoff), 70 | name = "FDR", 71 | guide=guide_colorbar(reverse=TRUE)) + 72 | scale_size(range = c(3,8), name="No. Shared\nMarker Pair") + 73 | geom_hline(yintercept=0, lty=4, col="black", lwd=1)+ 74 | 75 | theme_bw(base_size = 20, base_family = "serif") + 76 | theme( 77 | panel.grid.minor=element_blank(), 78 | panel.grid.major=element_blank() 79 | ) + 80 | labs(x="Cell Interaction",y="Enrichment Ratio", 81 | title="Cell Interaction Enrichment", 82 | base_size = 12, base_family = "serif",face="bold") + 83 | theme(legend.background = element_rect(linetype = 1, 84 | linewidth = 0.5, colour = 1), 85 | legend.position="right", 86 | legend.box = "vertical", 87 | legend.direction= "vertical", 88 | plot.margin = unit(c(1, 1, 1, 5), "lines"), 89 | panel.grid=element_blank(), 90 | legend.key.width = unit(0.5,"cm"), 91 | legend.title = element_text(face="bold", color="black", 92 | family = "serif", size=10), 93 | legend.text= element_text(face="bold", color="black", 94 | family = "serif", size=10), 95 | plot.title = element_text(hjust = 0.5), 96 | axis.text.x = element_text(face="bold", color="black", size=10, 97 | angle = 40, vjust = 1, hjust=1), 98 | axis.text.y = element_text(face="bold", color="black", size=13), 99 | axis.title.x = element_text(face="bold", color="black", size=15), 100 | axis.title.y = element_text(face="bold",color="black", size=15), 101 | axis.line.y = element_line(arrow = grid::arrow( 102 | length = unit(0.3, "cm"), ends = "last"))) + 103 | scale_y_continuous(limits=c(0, max), breaks=seq(0,max, 2),expand = c(0,0)) + 104 | guides(shape = "none") + 105 | annotate("text", x = -1, y = max, label = "Favorable\nOutcome")+ 106 | coord_cartesian(xlim = c(1,nrow(resdata[se,] )), 107 | clip = 'off') 108 | 109 | return(p) 110 | } 111 | -------------------------------------------------------------------------------- /R/Enrich.R: -------------------------------------------------------------------------------- 1 | ##' Generate marker pair background 2 | ##' 3 | ##' Given a gene pair A_B, it will generate 4 | ##' the background gene pairs A_B and B_A 5 | ##' 6 | ##' @param marker.pair a vector of marker pairs connected by "_" 7 | ##' @return A vector of background gene pairs 8 | ##' @export 9 | ##' @examples 10 | ##' \dontrun{ 11 | ##' data(Bindea2013c_COX_MP_SKCM06) 12 | ##' cox_res <- Bindea2013c_COX_MP_SKCM06 13 | ##' background <- TimiBG(marker.pair = row.names(cox_res)) 14 | ##' } 15 | ##' @author Chenyang Skylar Li 16 | TimiBG <- function(marker.pair = NULL){ 17 | 18 | # Examine required parameters------------------------------------------------- 19 | if (is.null(marker.pair)){ 20 | stop('The parameter "marker.pair" is required.') 21 | } 22 | 23 | xx <- marker.pair 24 | tmp <- unlist(strsplit(xx, "_")) 25 | nn <- length(xx) 26 | tmp1 <- tmp[(1:nn)*2-1] 27 | tmp2 <- tmp[(1:nn)*2-0] 28 | rxx <- paste(tmp2, tmp1, sep="_") 29 | background <- unique(c(xx,rxx)) # Total gene pairs 30 | message(length(background)," Background Pairs were generated from given ",length(marker.pair)," pairs") 31 | return(background) 32 | } 33 | 34 | ##' Enrichment Analysis 35 | ##' 36 | ##' It statistically determines the inter-interactions 37 | ##' by performing over-representation (enrichment analysis) 38 | ##' 39 | ##' @param gene a vector of gene symbol 40 | ##' @param geneset a data frame, column 1 shows cell (pair), 41 | ##' column 2 shows gene (pair) 42 | ##' @param background background genes or pairs 43 | ##' @param p.adj p.adjust.methods. 44 | ##' One of "holm", "hochberg", "hommel", "bonferroni", 45 | ##' "BH", "BY", "fdr", "none". The default is "BH". 46 | ##' @param core a numeric value shows the number of cores for parallel execution. 47 | ##' The default value is 1. 48 | ##' @param pair a logical value. If TRUE (default), 49 | ##' perform enrichment analysis in cell pair. 50 | ##' If using the function for general cell type enrichment analysis, 51 | ##' please choose FALSE. 52 | ##' @import foreach 53 | ##' @import doParallel 54 | ##' @return A dataframe of enrichment results including cell-cell interactions 55 | ##' @export 56 | ##' @examples 57 | ##' \dontrun{ 58 | ##' # Generate cell interaction Annotation: TimiCellPair 59 | ##' data(CellType_Bindea2013_cancer) 60 | ##' geneset <- CellType_Bindea2013_cancer 61 | ##' cell_pair <- TimiCellPair(geneset = geneset,core = 20) 62 | ##' # Select marker pairs A_B=1 associated with good prognosis 63 | ##' data(Bindea2013c_COX_MP_SKCM06) 64 | ##' cox_res <- Bindea2013c_COX_MP_SKCM06 65 | ##' GP <- rownames(cox_res)[which(cox_res$QV<0.05)] 66 | ##' # generate background: TimiBG 67 | ##' background <- TimiBG(marker.pair = row.names(cox_res)) 68 | ##' # Enrichment Analysis: TimiEnrich 69 | ##' res <- TimiEnrich(gene = GP, background = background, 70 | ##' geneset = cell_pair, p.adj = "BH",core=2) 71 | ##' 72 | ##' } 73 | ##' @author Chenyang Skylar Li 74 | 75 | TimiEnrich <- function(gene = NULL, 76 | background = NULL, 77 | geneset = NULL, 78 | p.adj = "BH", 79 | core = 1, 80 | pair=TRUE){ 81 | # examine required parameters------------------------------------------------ 82 | if (is.null(gene)){ 83 | stop('The parameter "gene" is required.') 84 | } 85 | if (is.null(background)){ 86 | stop('The parameter "background" is required.') 87 | } 88 | if (is.null(geneset)){ 89 | stop('The parameter "geneset" is required.') 90 | } 91 | if (sum(p.adj %in% 92 | c("holm", "hochberg", "hommel", 93 | "bonferroni","BH", "BY","fdr", "none")) !=1 ){ 94 | stop('The parameter "p.adj" is required.' , 95 | 'Please choose one of c("holm", "hochberg",' , 96 | ' "hommel", "bonferroni", "BH", "BY", "fdr", "none")') 97 | } 98 | # Parallel 99 | registerDoParallel(cores=core) 100 | 101 | ## prepare parameter for hypergeometric test--------------------------------- 102 | ## Annotated Cell Interaction X->Y | Not Annotated | Row Sum 103 | ## Prognostic Pair | k | n-k | n 104 | ## Not Prognostic | M-k | N+k-n-m | 105 | ## column Sum | M | N-M | N 106 | gene <- as.character(unique(gene)) 107 | bg <- as.character(unique(background)) 108 | ann <- unique(geneset[, 1]) 109 | gene_ann <- as.character(unique(geneset[, 2])) 110 | 111 | ## N is the total number of genes in the background distribution 112 | ## The background distribution by default is all the genes that have annotation. 113 | bg_ann<- intersect(bg,gene_ann) 114 | N <- length(bg_ann) 115 | # output 116 | 117 | res <- foreach (i = 1:length(ann), .combine=rbind) %dopar% { 118 | se <- which(geneset[, 1]==ann[i]) 119 | ## M is the number of genes within that distribution that are annotated 120 | ## (either directly or indirectly) to the gene set of interest 121 | M_gene <- unique(geneset[se, 2]) 122 | se <- which(M_gene %in% bg_ann) 123 | M_gene <- M_gene[se] 124 | M <- length(M_gene) 125 | ## n is the size of the list of genes of interest 126 | ## those genes that have no annotation should drop. 127 | n <- sum(gene %in% bg_ann) 128 | ## k is the number of genes within intereseting gene list which 129 | ## are annotated to the gene set. 130 | k_gene <- gene[which(gene %in% M_gene)] 131 | k <- length(k_gene) 132 | data.frame("Cell.Interaction" = ann[i], 133 | "No.Total.IMGP" = M, 134 | "No.Shared.IMGP" = k, 135 | "Enrichment.Ratio" = round(k*N/M/n,3), 136 | "P.Value" = phyper(k-1, M, N-M, n, lower.tail=FALSE), 137 | "Shared.IMGP" = paste(k_gene,collapse="/"), 138 | "Total.IMGP" = paste(M_gene,collapse="/")) 139 | } 140 | ## P adjust------------------------------------------------------------------ 141 | res$Adjust.P.Value <- p.adjust(res$P.Value, method=p.adj) 142 | res$Rank <- rank(res$P.Value,ties.method = "min") 143 | res <- res[order(res$P.Value,res$Adjust.P.Value), ] 144 | res$Index <- 1:nrow(res) 145 | if (pair == TRUE){ 146 | xx <- unlist(strsplit(res$Cell.Interaction,split = "_")) 147 | res$Favorable.Cell.Type <- xx[seq(1,length(xx),2)] 148 | res$Unfavorable.Cell.Type <- xx[seq(2,length(xx),2)] 149 | res <- res[, c(10,9,1,11:12,2:5,8,6:7)] 150 | } else { 151 | res <- res[, c(10,9,1:5,8,6:7)] 152 | 153 | } 154 | 155 | 156 | 157 | 158 | return (res) 159 | } 160 | 161 | 162 | -------------------------------------------------------------------------------- /R/Favorability.R: -------------------------------------------------------------------------------- 1 | ##' Calculate Favorability Score of cell types 2 | ##' 3 | ##' It calculates the favorability score of each cell type 4 | ##' based on TimiGP cell interaction network. 5 | ##' The favorability score includes favorable score and unfavorable score. 6 | ##' Favorable score: out-degree of the cell/sum of out-degree of all cell*100. 7 | ##' Unfavorable score: in-degree of the cell/sum of in-degree of all cell*100. 8 | ##' 9 | ##' @param resdata TimiGP enrichment result generated from TimiEnrich 10 | ##' @param condition A value in one of 11 | ##' c("P.Value","Adjust.P.Value","Permutation.FDR"), 12 | ##' which is the column name of resdata. 13 | ##' The default value is the "Adjust.P.Value". 14 | ##' @param cutoff A cutoff of condition used to filter cell interactions. 15 | ##' The default cutoff is 0.05. 16 | ##' @return A matrix of Favorability Score 17 | ##' which includes favorable score and unfavorable score. 18 | ##' Difference = Favorable.Score - Unfavorable.Score. 19 | ##' If Difference greater than 0, the cell type is classified as F(avorable) cell. 20 | ##' If Difference is negative, the cell type is classified as F(avorable) cell. 21 | ##' @import dplyr 22 | ##' @export 23 | ##' @examples 24 | ##' \dontrun{ 25 | ##' data("Bindea2013c_enrich") 26 | ##' res <- Bindea2013c_enrich 27 | ##' score <- TimiFS(res, cutoff = 0.05) 28 | ##' head(score) 29 | ##' } 30 | ##' @author Chenyang Skylar Li 31 | 32 | TimiFS<- function(resdata = NULL, 33 | condition = "Adjust.P.Value", 34 | cutoff = 0.05){ 35 | # Examine required parameters------------------------------------------------- 36 | if (is.null(resdata)){ 37 | stop('The parameter "resdata" is required.') 38 | } 39 | 40 | if (is.null(condition)){ 41 | stop('The parameter "condition" is required. Please choose one of c("P.Value","Adjust.P.Value","Permutation.FDR")') 42 | } else if(sum(condition %in% c("P.Value","Adjust.P.Value","Permutation.FDR")) !=1){ 43 | stop('Please choose one of c("P.Value","Adjust.P.Value","Permutation.FDR")') 44 | 45 | } 46 | 47 | resdata <- resdata[which(resdata[,condition] < cutoff),] 48 | message('Using cell-cell interactions(', 49 | condition, ' < ', cutoff, ')') 50 | # favorable cells------------------------------------------------------------- 51 | total_ct <- unique(c(resdata$Favorable.Cell.Type, 52 | resdata$Unfavorable.Cell.Type)) 53 | 54 | faCell <- table(resdata$Favorable.Cell.Type) %>% data.frame() 55 | se <- which(! total_ct %in% faCell$Var1) 56 | faCell <- faCell %>% 57 | rbind(data.frame(Var1=total_ct[se],Freq=rep(0,length(se)))) %>% 58 | mutate(F=Freq/sum(Freq) *100) 59 | 60 | dim(faCell) 61 | 62 | # unfavorable cell------------------------------------------------------------ 63 | unfaCell <- table(resdata$Unfavorable.Cell.Type) %>% data.frame() 64 | se <- which(! total_ct %in% unfaCell$Var1) 65 | unfaCell <- unfaCell %>% 66 | rbind(data.frame(Var1=total_ct[se],Freq=rep(0,length(se)))) %>% 67 | mutate(U=Freq/sum(Freq) *100) 68 | dim(unfaCell) 69 | 70 | # all cell ------------------------------------------------------------------- 71 | score <- merge(faCell,unfaCell,by="Var1") %>% data.frame() %>% 72 | mutate(diff=F-U) %>% 73 | arrange(-diff) %>% 74 | mutate(Var1 = factor(Var1, levels=Var1)) %>% 75 | filter(diff != 0) %>% 76 | mutate( group = ifelse(diff>0, "F","U"))%>% 77 | mutate(Rank = rank(-diff,ties.method = "min")) 78 | score$Index <- 1:nrow(score) 79 | score <- score[c(9,8,1:7)] 80 | names(score) <-c("Index", "Rank","Cell.Type","OutDegree","Favorable.Score", 81 | "Indegree","Unfavorable.Score", 82 | "Difference", 83 | "Group") 84 | 85 | 86 | return(score) 87 | } 88 | 89 | 90 | 91 | 92 | 93 | ##' Visualization of favorability score 94 | ##' 95 | ##' It generate a bar plot of the favorability score of cell type 96 | ##' to evaluate its favorable(orange,positive) or unfavorable(Blue,negative) role in prognosis. 97 | ##' 98 | ##' @param score Favorability score calculated from TimiFS 99 | ##' @param select A numeric vector of selected cell interactions according to "Index" column in resdata. 100 | ##' Default selection is all cell type. 101 | ##' @return A barplot of Favorability Score 102 | ##' @import dplyr 103 | ##' @export 104 | ##' @examples 105 | ##' \dontrun{ 106 | ##' data("Bindea2013c_enrich") 107 | ##' res <- Bindea2013c_enrich 108 | ##' score <- TimiFS(res) 109 | ##' head(score) 110 | ##' p <- TimiFSBar(score) 111 | ##' p 112 | ##' } 113 | ##' @author Chenyang Skylar Li 114 | 115 | TimiFSBar<- function(score = NULL, 116 | select=NULL){ 117 | # Examine required parameters------------------------------------------------- 118 | if (is.null(score)){ 119 | stop('The parameter "score" is required.') 120 | } 121 | 122 | if (!is.null(select)){ 123 | se <- which(score$Index %in% select) 124 | if(length(se) == 0|length(se) > nrow(score)) { 125 | stop('There are only ',nrow(score), 'cell types') 126 | } else { 127 | score <- score[se,] 128 | } 129 | 130 | } 131 | 132 | 133 | # plot------------------------------------------------------------------------ 134 | max <- ceiling(max(score$Favorable.Score)/10)*10 135 | min <- ceiling(max(score$Unfavorable.Score)/10)*10 136 | score$Cell.Type <- factor(score$Cell.Type,levels = score$Cell.Type) 137 | 138 | p <- ggplot() + 139 | geom_bar(data = score, 140 | mapping = aes(x = Cell.Type,y=Favorable.Score), 141 | width=0.8, position = position_dodge(width=0.01), 142 | stat="identity" ,alpha=0.5,fill="#fc4e2a") + 143 | geom_bar(data = score, 144 | mapping = aes(x = Cell.Type,y=-Unfavorable.Score ), 145 | width=0.8, position = position_dodge(width=0.01), 146 | stat="identity" ,alpha=0.5,fill="#253494") + 147 | theme_bw(base_size = 20, base_family = "serif") + 148 | theme( 149 | panel.grid.minor=element_blank(), 150 | panel.grid.major=element_blank() 151 | ) + 152 | labs(x="Cell Type",y="Favorability Score", 153 | title=paste0("Favorability"), 154 | base_size = 22, base_family = "serif",face="bold") + 155 | theme(legend.background = element_rect(linetype = 1, size = 0.5, colour = 1), 156 | plot.margin = unit(c(1, 1, 1, 5), "lines"), 157 | legend.position="right", 158 | legend.box = "vertical", 159 | legend.direction= "vertical", 160 | panel.grid=element_blank(), 161 | legend.key.width = unit(0.5,"cm"), 162 | legend.title = element_text(face="bold", color="black",family = "serif", size=10), 163 | legend.text= element_text(face="bold", color="black",family = "serif", size=10), 164 | plot.title = element_text(hjust = 0.5), 165 | axis.text.x = element_text(face="bold", color="black", size=13, 166 | angle = 60, vjust = 1, hjust=1), 167 | axis.text.y = element_text(face="bold", color="black", size=15), 168 | axis.title.x = element_text(face="bold", color="black", size=17), 169 | axis.title.y = element_text(face="bold",color="black", size=17), 170 | axis.line.y = element_line(arrow = grid::arrow(length = unit(0.3, "cm"), ends = "both"))) + 171 | scale_y_continuous(limits=c(-min, max), breaks=seq(-min,max, 10),expand = c(0,0)) + 172 | geom_hline(yintercept = 0,lty=1,size=1) + 173 | annotate("text", x = -1.5, y = max, label = "Favorable\nScore")+ 174 | annotate("text", x = -1.5, y = -min, label = "Unfavorable\nScore")+ 175 | coord_cartesian(xlim = c(1,nrow(score)), 176 | clip = 'off') 177 | return(p) 178 | } 179 | 180 | -------------------------------------------------------------------------------- /R/Fisher.R: -------------------------------------------------------------------------------- 1 | ##' Find marker pairs associated with response to therapy 2 | ##' 3 | ##' Perform fisher test (two sided) to look for marker pair associated with response to therapy. 4 | ##' 5 | ##' @param mps a matrix of Marker Pair Score 6 | ##' @param info a data.frame in which the 1st column contains 7 | ##' two groups on response to therapy, "Responder == 1" & "Non-Responder == 0" 8 | ##' and row name is patient ID. 9 | ##' @param p.adj p.adjust.methods. 10 | ##' One of "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none" 11 | ##' The default value is "BH". 12 | ##' @param parallel a logical value. If TRUE, enable parallel computing. 13 | ##' The default value if FALSE 14 | ##' @param core a numeric value shows the number of cores for parallel execution. 15 | ##' The default value is 1. 16 | ##' @return Result of fisher test 17 | ##' (Rowname: Marker Pair,PV: P-Value,QV: Adjust P-value). 18 | ##' @import dplyr 19 | ##' @import foreach 20 | ##' @import doParallel 21 | ##' @export 22 | ##' @examples 23 | ##' \dontrun{ 24 | ##' # See example07 for more details 25 | ##' # Load the example data 26 | ##' data(TNBCaPD1info) 27 | ##' data(TNBCaPD1rna) 28 | ##' # Load the example cell type annotation 29 | ##' data("CellType_TNBC_aPDL1") 30 | ##' geneset <- CellType_TNBC_aPDL1 31 | ##' marker <- unique(geneset$Gene) 32 | ##' # Preprocess 33 | ##' info <- TNBCaPD1info 34 | ##' rna <- TimiPrePropress(marker = marker, cohort = rownames(info), 35 | ##' log = F, GMNorm = T, rna = TNBCaPD1rna) 36 | ##' # Generate marker pair score 37 | ##' mps <- TimiGenePair(rna) 38 | ##' # Use the function TimiFisher 39 | ##' res <- TimiFisher(mps = mps,info = info,p.adj = "BH") 40 | ##' # Assign results 41 | ##' mps <- res$mps 42 | ##' fisher_res <- res$fisher_res 43 | ##' } 44 | ##' @author Chenyang Skylar Li 45 | 46 | TimiFisher <- function(mps = NULL, 47 | info = NULL, 48 | p.adj = "BH", 49 | parallel = FALSE, 50 | core = 1){ 51 | # examine required parameters 52 | if (is.null(mps)){ 53 | stop('The parameter "mps" is required. ') 54 | } 55 | 56 | if (is.null(info)){ 57 | stop('The parameter "info" is required. ') 58 | } 59 | 60 | if (is.null(p.adj)){ 61 | stop('The parameter "p.adj" is required. Please choose one of c("holm", "hochberg", "hommel", "bonferroni","BH", "BY","fdr", "none")') 62 | } 63 | 64 | 65 | if (all((colnames(mps) == rownames(info)) != TRUE) ) { 66 | comSam <- intersect(row.names(info), colnames(mps)) 67 | if (length(comSam) > 0) { 68 | mps <- mps[,comSam] 69 | info <- info[comSam,] 70 | } else { 71 | stop('Samples are different between Gene pair score and clinical info') 72 | } 73 | if (all((colnames(mps) == rownames(info)) != TRUE) ) { 74 | stop('Samples are different between Gene pair score and clinical info') 75 | } 76 | 77 | } 78 | 79 | # fisher function ------------------------------------------------------------ 80 | Myfun <- function(mytag = NULL, 81 | info = NULL, 82 | logic = T # T: 0 or 1; F: numeric 83 | ){ 84 | if (logic == T){ 85 | mytag <- as.factor(mytag) 86 | 87 | # Perform fisher test 88 | tmp <- as.data.frame(cbind(info, mytag)) 89 | stat <- as.matrix(table(tmp)) 90 | stat <-t(stat[c("1","0"),c("1","0")]) 91 | test <- fisher.test(stat,alternative = "two.sided") 92 | res <- c( test$estimate, test$p.value) 93 | names(res) <- c("OR","PV") 94 | return (res) 95 | 96 | } else if (logic == F) { 97 | 98 | stop("The function has not been relesed and please stay tuned. 99 | For the current version, please set `cont = FALSE` in `TimiGenePair()`.") 100 | 101 | } 102 | 103 | 104 | } 105 | # perform fisher test /logistical regression --------------------------------- 106 | # examine the mps is generated from logical relation or continuous relation 107 | 108 | if (parallel == F) { # No parallel, use apply 109 | message("------------- Calculating -------------") 110 | message("Please be patient. This step usually takes approximately 1 minutes.") 111 | message("The computation time may be increased if there are a larger number of cell type markers (e.g., > 1000 markers for > 30 mins).") 112 | message('To speed up, you can enable parallel computing by setting "parallel = T" and the number of cores (core).') 113 | if (is.logical(mps) == T) { 114 | 115 | # perform fisher test <- logical ------------------------------------------------------ 116 | Myres <- apply(mps * 1, 1, function (x) 117 | Myfun(mytag = x,info = info, logic = T)) 118 | 119 | } else if (is.numeric(mps) == T) { 120 | # perform logistical regression <- continuous --------------------------------------------------- 121 | Myres <- apply(mps, 1, function (x) 122 | Myfun(mytag = x,info = info, logic = F)) 123 | 124 | } else { 125 | stop('The matrix are neither logical nor numeric values') 126 | } 127 | } else if (parallel == T) { # parallel, select core 128 | message("Enable parallel computing.") 129 | if (core == 1) { 130 | warning("Only 1 core specified. You may want to change core > 1") 131 | } 132 | 133 | message("------------- Calculating -------------") 134 | message("Please be patient.") 135 | message("The computation time may be increased if there are a larger number of cell type markers.") 136 | registerDoParallel(cores=core) 137 | 138 | if (is.logical(mps) == T) { 139 | 140 | # perform fisher test <- logical ------------------------------------------------------ 141 | Myres <- foreach (i = 1:nrow(mps), .combine=cbind) %dopar% { 142 | Myfun(mytag = mps[i,]*1,info = info, logic = T) 143 | } 144 | 145 | } else if (is.numeric(mps) == T) { 146 | # perform logistical regression <- continuous --------------------------------------------------- 147 | Myres <- foreach (i = 1:nrow(mps), .combine=cbind) %dopar% { 148 | Myfun(mytag = mps[i,]*1,info = info, logic = F) 149 | } 150 | 151 | } else { 152 | stop('The matrix are neither logical nor numeric values') 153 | } 154 | 155 | } 156 | 157 | Myres <- Myres %>% 158 | t() %>% 159 | data.frame() %>% 160 | mutate(QV = p.adjust(PV, method=p.adj)) 161 | row.names(Myres) <- row.names(mps) 162 | 163 | 164 | # change pair direction of fisher result: ------------------------------------ 165 | # all OR > 1 == MPS score associated with responders 166 | # reverse OR < 1 167 | se <- which(Myres$OR < 1) 168 | 169 | message("The direction of ",length(se)," marker pairs were reversed") 170 | 171 | xx <- row.names(Myres[se,]) 172 | xx <- unlist(strsplit(xx, "_")) 173 | xx1 <- xx[seq(1,length(xx),2)] 174 | xx2 <- xx[seq(2,length(xx),2)] 175 | xx <- paste(xx2, xx1, sep="_") 176 | 177 | Myres$OR[se] <- 1/Myres$OR[se] 178 | rownames(Myres)[se] <- xx 179 | 180 | # change pair direction and reverse value of marker pair score --------------- 181 | rownames(mps)[se] <- xx 182 | 183 | if (is.logical(mps) == T) { 184 | mps[se,] <- !mps[se,] 185 | } else if (is.numeric(mps) == T) { 186 | mps[se,] <- -mps[se,] 187 | } else { 188 | stop('The matrix are neither logical nor numeric values') 189 | } 190 | 191 | Myres <-Myres[order(Myres[,2]),] 192 | res <- list("mps" = mps,"fisher_res" = Myres) 193 | 194 | return(res) 195 | 196 | } 197 | 198 | 199 | -------------------------------------------------------------------------------- /R/Pairwise.R: -------------------------------------------------------------------------------- 1 | ##' Capture logical/continuous relation between marker pairs 2 | ##' 3 | ##' Default: Capture logical relation of any two marker pairs, 4 | ##' and generate a matrix of Marker Pair Score: 5 | ##' 1 or TRUE = the expression of gene A > that of gene B, 6 | ##' 0 or FALSE = the expression of gene A < that of gene B. 7 | ##' \cr 8 | ##' Optional: Capture continuous relation of any two marker pairs, 9 | ##' and generate a matrix of Marker Pair Score: 10 | ##' the expression of gene A - that of gene B, 11 | ##' 12 | ##' @param rna a data.frame of preprocessed transcriptomic profile 13 | ##' @param both a logical value. 14 | ##' The default is FALSE that only keep A_B pairs 15 | ##' If TRUE, keep both A_B and B_A pairs, this is only for ssTimiGP. 16 | ##' @param cont a logical value. If TRUE, capture the continuous relation. 17 | ##' The default is FALSE 18 | ##' @return a matrix of Marker Pair Score 19 | ##' @export 20 | ##' @examples 21 | ##' \dontrun{ 22 | ##' data("SKCM06info") 23 | ##' data("SKCM06rna") 24 | ##' data("Immune_Marker_n1293") 25 | ##' dim(SKCM06info) 26 | ##' info <- TimiCheckEvent(SKCM06info) 27 | ##' dim(info) 28 | ##' dim(SKCM06rna) 29 | ##' rna <- TimiPrePropress(gene = Immune_Marker_n1293,rna = SKCM06rna,cohort = rownames(info)) 30 | ##' # TimiGenePair 31 | ##' mps <- TimiGenePair(rna) 32 | ##' dim(mps) 33 | ##' } 34 | ##' @author Chenyang Skylar Li 35 | 36 | TimiGenePair <- function(rna = NULL, 37 | both = FALSE, 38 | cont = FALSE){ 39 | 40 | # examine required parameters------------------------------------------------- 41 | if (is.null(rna)){ 42 | stop('The parameter "rna" is required. ') 43 | } 44 | 45 | if (is.logical(both) == F){ 46 | stop('both is a logical value. Please set it to TRUE or FALSE') 47 | } 48 | 49 | if (is.logical(cont) == F){ 50 | stop('cont is a logical value. Please set it to TRUE or FALSE') 51 | } 52 | 53 | if (cont == T & (all(apply(rna,1,median) == 0) == T)) { 54 | stop('If you want to capture continuous relation between gene pairs, 55 | please do not use gene-wise median normalization. 56 | Please set "GMNorm = F" in "TimiPrePropress" then re-run this function') 57 | } 58 | 59 | message("Generating marker pairs") 60 | ### S1: pairwise comparision ------------------------------------------------- 61 | irg <- rownames(rna) 62 | irgp <- outer(irg, irg, paste, sep="_") 63 | if (cont == FALSE) { 64 | message("The default is to capture logical relation") 65 | myfun <- function(myvec){as.vector(outer(myvec, myvec, ">"))} 66 | } else if (cont == TRUE) { 67 | message("You choose to capture continuous relation") 68 | myfun <- function(myvec){as.vector(outer(myvec, myvec, "-"))} 69 | } 70 | 71 | irgp_res <- apply(rna, 2, myfun) 72 | row.names(irgp_res) <- irgp 73 | 74 | ### S2: Remove B_A, A_A pairs, only keep A_B---------------------------------- 75 | xx <- row.names(irgp_res) 76 | nn <- length(xx) 77 | tmp <- unlist(strsplit(xx, "_")) 78 | tmp1 <- tmp[(1:nn)*2-1] 79 | tmp2 <- tmp[(1:nn)*2-0] 80 | if (both == F) { # remove B_A, A_A pairs 81 | se <- which(tmp1>tmp2) 82 | irgp_res <- irgp_res[se,] 83 | dim(irgp_res) 84 | } else if ( both == T) { # remove A_A pairs 85 | message("You choose to keep both A_B and B_A pairs. Please note this is only used for ssTimiGP") 86 | se <- which(tmp1!=tmp2) 87 | irgp_res <- irgp_res[se,] 88 | dim(irgp_res) 89 | } 90 | 91 | 92 | ### S3: filter GPs 93 | if (cont == FALSE) { 94 | ### choose GPs with at least 10% samples in both groups------------------- 95 | n.thr <- round(ncol(rna)*0.1) 96 | xx1 <- apply(irgp_res==1, 1, sum) 97 | xx2 <- apply(irgp_res==0, 1, sum) 98 | se <- which(xx1>=n.thr & xx2>=n.thr) 99 | 100 | message(nrow(irgp_res)-length(se)," marker pairs were filtered out") 101 | irgp_res <- irgp_res[se,] 102 | dim(irgp_res) 103 | 104 | message(nrow(irgp_res)," marker pairs were produced") 105 | } else if (cont == TRUE) { 106 | ### choose GPs with difference > 0.1 across patients ----------------------- 107 | min_range <- 0.1 108 | se <- apply(irgp_res, 1, function(x) { (max(x) - min(x)) > min_range }) 109 | message(nrow(irgp_res)-length(se)," marker pairs were filtered out (CONT)") 110 | irgp_res <- irgp_res[se,] 111 | message(nrow(irgp_res)," marker pairs were produced (CONT)") 112 | } 113 | 114 | return(irgp_res) 115 | } 116 | 117 | 118 | 119 | ##' Generate cell pair representing potential interaction using 120 | ##' the corresponding marker pair annotation 121 | ##' 122 | ##' Given any two different cell types, 123 | ##' Cell A has markers a1 and a2 and cell B has markers b1 and b2. 124 | ##' Cell pair A_B includes marker pairs: a1_b1, a1_b2, a2_b1, a2_b2; 125 | ##' Cell pair B_A includes marker pairs: b1_a1, b1_a2, b2_a1, b2_a2 126 | ##' 127 | ##' 128 | ##' @param geneset a data.frame of cell markers, 129 | ##' in which the 1st column is cell type, 130 | ##' the 2nd column is the marker gene 131 | ##' and the 3rd column is the name of the dataset (optional) 132 | ##' @param core a numeric value shows the number of cores 133 | ##' to use for parallel execution. The default value is 1. 134 | ##' @param dataset specified at least 1 dataset occured in the 3rd column of geneset 135 | ##' @import foreach 136 | ##' @import doParallel 137 | ##' @return A dataframe of Cell pair and the corresponding marker pair 138 | ##' @export 139 | ##' @examples 140 | ##' \dontrun{ 141 | ##' data(CellType_Galon2013_cancer) 142 | ##' geneset <- CellType_Galon2013_cancer 143 | ##' cell_pair <- TimiCellPair(geneset = geneset,core = 2) 144 | ##' } 145 | ##' @author Chenyang Skylar Li 146 | TimiCellPair <- function(geneset = NULL, 147 | dataset = NULL, 148 | core = 1){ 149 | 150 | # examine required parameters------------------------------------------------- 151 | if (is.null(geneset)){ 152 | stop('The parameter "geneset" is required. ') 153 | } 154 | # Parallel 155 | registerDoParallel(cores=core) 156 | # optional 3rd column dataset------------------------------------------------- 157 | if (ncol(geneset) == 3) { 158 | 159 | num <- table(geneset[3]) 160 | if(length(num) > 1 & is.null(dataset)){ 161 | stop('There are more than 1 datasets. Please choose one.') 162 | } else if (length(num) == 1 & is.null(dataset)){ 163 | dataset <- names(num) 164 | } 165 | 166 | if (!is.null(dataset)) { 167 | se <- which(geneset[,3] %in% dataset) 168 | if (length(se) == 0){ 169 | stop('Given dataset is different from 3rd column of geneset.') 170 | } else{ 171 | set <- geneset[se, 1:2] 172 | } 173 | 174 | } 175 | } 176 | 177 | if (ncol(geneset) == 2){ 178 | set <- geneset 179 | } 180 | 181 | 182 | 183 | # Cell Pair ------------------------------------------------------------------ 184 | ann <- unique(set[, 1]) 185 | if(length(ann) <=1){ 186 | stop('Less than 2 cell types were found.') 187 | } 188 | ann_int <- outer(ann, ann, paste, sep="_") 189 | nn <- length(ann_int) 190 | tmp <- unlist(strsplit(ann_int, "_")) 191 | tmp1 <- tmp[(1:nn)*2-1] 192 | tmp2 <- tmp[(1:nn)*2-0] 193 | se <- which(tmp1 != tmp2) 194 | ann_int <- ann_int[se] 195 | # Marker pair annoation 196 | geneset_cell_pair <- foreach (i = 1:length(ann_int), .combine=rbind) %dopar% { 197 | 198 | 199 | ann_i <- unlist(strsplit(ann_int[i], "_")) 200 | 201 | se1 <- which(set[, 1]==ann_i[1]) 202 | se2 <- which(set[, 1]==ann_i[2]) 203 | 204 | xx1 <- set[se1, 2] 205 | xx2 <- set[se2, 2] 206 | 207 | xx <- outer(xx1, xx2, paste, sep="_") 208 | nn <- length(xx) 209 | tmp <- unlist(strsplit(xx, "_")) 210 | tmp1 <- tmp[(1:nn)*2-1] 211 | tmp2 <- tmp[(1:nn)*2-0] 212 | se <- which(tmp1 != tmp2) 213 | xx <- xx[se] 214 | nn <- length(xx) 215 | data.frame("Cell.Pair" = rep(ann_int[i],nn), 216 | "Marker.Pair" = xx) 217 | 218 | } 219 | return(geneset_cell_pair) 220 | } 221 | -------------------------------------------------------------------------------- /R/Permutation.R: -------------------------------------------------------------------------------- 1 | ##' Permutation of marker genes to control FDR 2 | ##' 3 | ##' It conservatively permutates marker gene sets for all cell types 4 | ##' by shuffling their marker genes while preserving the sizes of their sets. 5 | ##' This permutation breaks the underlying association 6 | ##' between the genes and the cell types, 7 | ##' which enables the examination of cell-type marker quality 8 | ##' and the control of false positives in identifying cell interactions. 9 | ##' It exports the FDR (Q value) of each interaction. 10 | ##' 11 | ##' @param resdata TimiGP enrichment result generated from TimiEnrich 12 | ##' @param geneset a data.frame of cell markers used in TimiCellPair, 13 | ##' in which the 1st column is cell type, 14 | ##' the 2nd column is the marker gene 15 | ##' and the 3rd column is the name of the dataset (optional) 16 | ##' @param gene a vector of gene symbol used in TimiEnrich 17 | ##' @param background background genes or pairs used in TimiEnrich 18 | ##' @param niter A numeric value used to determine the number of permutation. 19 | ##' The default cutoff is 100. 20 | ##' @param core a numeric value shows the number of cores 21 | ##' for parallel execution. The default value is 1. 22 | ##' @return A new column "Permutation.FDR" is appended to 23 | ##' dataframe of cell-cell interactions generated from TimiEnrich 24 | ##' @export 25 | ##' @examples 26 | ##' \dontrun{ 27 | ##' data("Bindea2013c_enrich") 28 | ##' res <- Bindea2013c_enrich 29 | ##' res <- TimiPermFDR(resdata = res, geneset = geneset, gene = GP, 30 | ##' background = background, niter = 100, core = 20) 31 | ##' head(score) 32 | ##' } 33 | ##' @author Chenyang Skylar Li 34 | 35 | TimiPermFDR <- function(resdata = NULL, 36 | geneset = NULL, 37 | gene = NULL, 38 | background = NULL, 39 | niter = 100, 40 | core = 1){ 41 | 42 | # Examine required parameters------------------------------------------------- 43 | if (is.null(resdata)){ 44 | stop('The parameter "resdata" is required.') 45 | } 46 | if (is.null(geneset)){ 47 | stop('The parameter "geneset" is required. ') 48 | } 49 | if (is.null(gene)){ 50 | stop('The parameter "gene" is required.') 51 | } 52 | if (is.null(background)){ 53 | stop('The parameter "background" is required.') 54 | } 55 | 56 | 57 | # Parallel 58 | registerDoParallel(cores=core) 59 | 60 | # Permutation ---------------------------------------------------------------- 61 | message("--------------- Run ", niter, 62 | " permutations. Please be patient ---------------" ) 63 | permutation_res <- data.frame() 64 | for (seed in 1:niter) { 65 | set.seed(seed) 66 | 67 | # Shuffle marker gene set 68 | perm.set <- geneset 69 | mygen <- perm.set$Gene 70 | perm.set$Gene <- mygen[sample(1:length(mygen))] 71 | 72 | message("Permeutation#",seed, 73 | ": Different / Total markers: ", 74 | sum(perm.set$Gene != geneset$Gene),"/", nrow(geneset) ) 75 | 76 | # Run TimiGP using shuffled cell-type marker sets 77 | cell_pair <- TimiCellPair(geneset = perm.set,core = core) 78 | 79 | res <- TimiEnrich(gene = gene, background = background, 80 | geneset = cell_pair, p.adj = "none",core=core) 81 | 82 | res$seed <- seed 83 | permutation_res <- rbind(permutation_res,res) 84 | } 85 | # Permutation FDR ------------------------------------------------------------ 86 | message("--------------- Permutation done. Calculating FDR ---------------") 87 | resdata$Permutation.FDR <- NULL 88 | 89 | for (i in 1:nrow(resdata)) { 90 | k <- resdata$Rank[i] 91 | p_k <- resdata$P.Value[i] 92 | resdata$Permutation.FDR[i] <- min( 93 | sum(permutation_res$P.Value <= p_k)/k/niter,1) 94 | } 95 | resdata <- resdata[c(1:10,13,11:12)] 96 | 97 | message('The permutation has been succesfully perfomed.', 98 | ' Please check the new column "Permutation.FDR"') 99 | 100 | return(resdata) 101 | } 102 | 103 | 104 | -------------------------------------------------------------------------------- /R/Preprocess.R: -------------------------------------------------------------------------------- 1 | ##' Check Clinical Info 2 | ##' 3 | ##' Check Event and Time-to-event; remove NAs and time-to-event <=0 4 | ##' 5 | ##' 6 | ##' @param info a data.frame in which the 1st column is event 7 | ##' and the 2nd column is days-to-event. 8 | ##' @importFrom survival Surv 9 | ##' @return filtered clinical info 10 | ##' @export 11 | ##' @examples 12 | ##' \dontrun{ 13 | ##' data(SKCM06info) 14 | ##' dim(SKCM06info) 15 | ##' info <- TimiCheckEvent(SKCM06info) 16 | ##' dim(info) 17 | ##' } 18 | ##' @author Chenyang Skylar Li 19 | 20 | TimiCheckEvent <- function(info = NULL){ 21 | 22 | # examine required parameters ------------------------------------------------ 23 | if (is.null(info)){ 24 | stop('The parameter "info" is required. ') 25 | } 26 | 27 | # Remove NAs ----------------------------------------------------------------- 28 | se1 <- which(is.na(info[1])) 29 | se2 <- which(is.na(info[2])) 30 | y=Surv(as.numeric(info[,2]), as.numeric( info[,1])) 31 | # Remove time <=0------------------------------------------------------------- 32 | se3 <- which(y[, "time"] <= 0) 33 | se4 <- which(is.na(y)) 34 | se <- unique(c(se1,se2,se3,se4)) 35 | if (length(se) != 0){ 36 | info <- info[-se,] 37 | } 38 | 39 | message(length(se), " individuals were filtered out due to NAs or time <= 0") 40 | return(info) 41 | } 42 | 43 | 44 | 45 | 46 | ##' Preprocess Transctiptomic profile 47 | ##' 48 | ##' Given the transcriptomic profile, marker gene list, clinical information, 49 | ##' this function will return the marker gene expression in selected cohort, 50 | ##' after log transformation and gene wise median normalization 51 | ##' 52 | ##' 53 | ##' @param marker a vector of marker gene list. 54 | ##' @param rna a data.frame of transcriptomic profile, 55 | ##' in which row names are genes and colnames are individuals. 56 | ##' @param cohort a vector of selected individuals. 57 | ##' @param log logical value: 58 | ##' if TRUE, log transformation will be performed; The default is TRUE. 59 | ##' @param GMNorm logical value: 60 | ##' if TRUE, gene wise median normalization will be performed; The default is TRUE. 61 | ##' @return Preprocessed transctiptomic profile 62 | ##' @export 63 | ##' @examples 64 | ##' \dontrun{ 65 | ##' data("SKCM06info") 66 | ##' data("SKCM06rna") 67 | ##' data("Immune_Marker_n1293") 68 | ##' dim(SKCM06info) 69 | ##' info <- TimiCheckEvent(SKCM06info) 70 | ##' dim(info) 71 | ##' dim(SKCM06rna) 72 | ##' rna <- TimiPrePropress(gene = Immune_Marker_n1326,rna = SKCM06rna,cohort = rownames(info), log = T,GMNorm = T) 73 | ##' dim(rna) 74 | ##' } 75 | ##' @author Chenyang Skylar Li 76 | TimiPrePropress <- function(marker, 77 | rna = NULL, 78 | cohort, 79 | log=TRUE, 80 | GMNorm=TRUE){ 81 | 82 | # examine required parameters------------------------------------------------- 83 | 84 | if (is.null(rna)){ 85 | stop('The parameter "rna" is required. ') 86 | } 87 | 88 | 89 | # Extract cohort-------------------------------------------------------------- 90 | if (is.null(cohort)){ 91 | warning('No selected cohort. Use the cohort in transcriptiomic profile') 92 | } else { 93 | se1 <- which(colnames(rna) %in% cohort) 94 | if (length(se1) == 0) { 95 | warning('No individual was found in the transcriptome. Use the enrire cohort.') 96 | } else if (length(se1) > 0 & length(se1) < 5) { 97 | warning('No.Individuals < 5 was found in the transcriptome. Use the enrire cohort.') 98 | } else { 99 | rna <- rna[,se1] 100 | } 101 | } 102 | 103 | 104 | # Extract marker-------------------------------------------------------------- 105 | if (is.null(cohort)){ 106 | warning('No markers. Use the gene in transcriptiomic profile') 107 | } else { 108 | se2 <- which(rownames(rna) %in% marker) 109 | if (length(se2) == 0) { 110 | stop('No markers was found in the transcriptome. Please check marker ID') 111 | } else { 112 | rna <- rna[se2,] 113 | } 114 | } 115 | 116 | 117 | # remove genes with low expressions------------------------------------------- 118 | xx <- apply(rna>0, 1, sum) 119 | se3 <- which(xx>=ncol(rna)*0.5) 120 | if (length(se3) == 0){ 121 | stop('All markers were in a low expression level') 122 | } 123 | rna <- rna[se3,] 124 | message(nrow(rna)-length(se3)," markers with low expressions were filtered out") 125 | 126 | # log transformatio----------------------------------------------------------- 127 | if(log == TRUE){ 128 | rna <- log10(rna+1) 129 | } 130 | 131 | # gene wise median normalization --------------------------------------------- 132 | if(GMNorm == TRUE){ 133 | xx <- apply(rna, 1, median) 134 | rna <- rna-xx 135 | } 136 | idx <- order(row.names(rna)) 137 | rna <- rna[idx,] 138 | return(rna) 139 | } 140 | -------------------------------------------------------------------------------- /R/data.R: -------------------------------------------------------------------------------- 1 | #' Cell Type in melanoma microenvironment generated from Hughes2020 and Tirosh2016 with cancer cells 2 | #' 3 | #' A dataset containing the cell type and markers annotated by Tirosh2016 4 | #' 5 | #' @docType data 6 | #' 7 | #' @usage data(CellType_Tirosh2016_melanoma_TME) 8 | #' 9 | #' @keywords datasets 10 | #' 11 | #' @format A data frame with 391 rows and 3 variables: 12 | #' \describe{ 13 | #' \item{CellType}{Immune cell type, skin cell type and cancer cell type} 14 | #' \item{Gene}{Marker gene of the cell type} 15 | #' \item{Dataset}{The source of the annotation} 16 | #' } 17 | #' 18 | #' @references Tirosh, I., Izar, B., Prakadan, S. M., Wadsworth, M. H., Treacy, D., Trombetta, J. J., ... & Garraway, L. A. (2016). Dissecting the multicellular ecosystem of metastatic melanoma by single-cell RNA-seq. Science, 352(6282), 189-196. 19 | #' 20 | #' @source Modification can be found in inst/extdata/build_CellType_Tirosh2016_melanoma_TME.R 21 | "CellType_Tirosh2016_melanoma_TME" 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | #' Cell Type generated from Bindea2013 with cancer cells 30 | #' 31 | #' A dataset containing the cell type and markers annotated by Bindea2013 32 | #' 33 | #' @docType data 34 | #' 35 | #' @usage data(CellType_Bindea2013_cancer) 36 | #' 37 | #' @keywords datasets 38 | #' 39 | #' @format A data frame with 545 rows and 3 variables: 40 | #' \describe{ 41 | #' \item{CellType}{Immune cell type and cancer cell type} 42 | #' \item{Gene}{Marker gene of the cell type} 43 | #' \item{Dataset}{The source of the annotation} 44 | #' } 45 | #' 46 | #' @references Bindea, G., Mlecnik, B., Tosolini, M., Kirilovsky, A., Waldner, M., 47 | #' Obenauf, A. C., ... & Galon, J. (2013). Spatiotemporal dynamics of intratumoral 48 | #' immune cells reveal the immune landscape in human cancer. Immunity, 39(4), 782-795. 49 | #' 50 | #' @source Modification can be found in inst/extdata/build_CellType_Bindea2013_cancer.R 51 | "CellType_Bindea2013_cancer" 52 | 53 | 54 | 55 | 56 | #' Immune Cell Type generated from LM22 57 | #' 58 | #' A dataset containing the cell type and markers annotated by LM22, 59 | #' which is the cell-type signature of CIBERSORT and CIBERSORTx. 60 | #' 61 | #' @docType data 62 | #' 63 | #' @usage data(CellType_Newman2015_LM22) 64 | #' 65 | #' @keywords datasets 66 | #' 67 | #' @format A data frame with 1140 rows and 3 variables: 68 | #' \describe{ 69 | #' \item{CellType}{Immune cell type} 70 | #' \item{Gene}{Marker gene of the cell type} 71 | #' \item{Dataset}{The source of the annotation} 72 | #' } 73 | #' 74 | #' @references Newman, A. M., Liu, C. L., Green, M. R., Gentles, A. J., Feng, W., Xu, Y., ... & Alizadeh, A. A. (2015). Robust enumeration of cell subsets from tissue expression profiles. Nature methods, 12(5), 453-457. 75 | #' 76 | #' @source Modification can be found in inst/extdata/build_CellType_Newman2015_LM22.R 77 | "CellType_Newman2015_LM22" 78 | 79 | 80 | 81 | 82 | 83 | 84 | #' Immune Cell Type generated from Charoentong2017, Bindea2013, Xu2018 85 | #' 86 | #' A dataset containing the cell type and markers annotated by Charoentong2017, Bindea2013, Xu2018 87 | #' 88 | #' @docType data 89 | #' 90 | #' @usage data(CellType_Charoentong2017_Bindea2013_Xu2018_Immune) 91 | #' 92 | #' @keywords datasets 93 | #' 94 | #' @format A data frame with 1375 rows and 3 variables: 95 | #' \describe{ 96 | #' \item{CellType}{Immune cell type} 97 | #' \item{Gene}{Marker gene of the cell type} 98 | #' \item{Dataset}{The source of the annotation} 99 | #' } 100 | #' 101 | #' @references Charoentong, P., Finotello, F., Angelova, M., Mayer, C., Efremova, M., Rieder, D., ... & Trajanoski, Z. (2017). Pan-cancer immunogenomic analyses reveal genotype-immunophenotype relationships and predictors of response to checkpoint blockade. Cell reports, 18(1), 248-262. 102 | #' @references Bindea, G., Mlecnik, B., Tosolini, M., Kirilovsky, A., Waldner, M., Obenauf, A. C., ... & Galon, J. (2013). Spatiotemporal dynamics of intratumoral immune cells reveal the immune landscape in human cancer. Immunity, 39(4), 782-795. 103 | #' @references Xu, L., Deng, C., Pang, B., Zhang, X., Liu, W., Liao, G., ... & Li, X. (2018). Xu2018: a web server for resolving tumor immunophenotype profiling. Cancer research, 78(23), 6575-6580. 104 | #' 105 | #' @source Modification can be found in inst/extdata/build_CellType_Charoentong2017_Bindea2013_Xu2018_Immune.R 106 | "CellType_Charoentong2017_Bindea2013_Xu2018_Immune" 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | #' T Cell Subtypes generated from Zheng2021 117 | #' 118 | #' A dataset containing the cell type and markers annotated by Zheng2021 119 | #' 120 | #' @docType data 121 | #' 122 | #' @usage data(CellType_Zheng2021_Tcell) 123 | #' 124 | #' @keywords datasets 125 | #' 126 | #' @format A data frame with 926 rows and 3 variables: 127 | #' \describe{ 128 | #' \item{CellType}{T cell subtype} 129 | #' \item{Gene}{Marker gene of the cell type} 130 | #' \item{Dataset}{The source of the annotation} 131 | #' } 132 | #' 133 | #' @references Zheng, L., Qin, S., Si, W., Wang, A., Xing, B., Gao, R., ... & Zhang, Z. (2021). Pan-cancer single-cell landscape of tumor-infiltrating T cells. Science, 374(6574), abe6474. 134 | #' 135 | #' @source Modification can be found in inst/extdata/build_CellType_Zheng2021_Tcell.R 136 | "CellType_Zheng2021_Tcell" 137 | 138 | 139 | 140 | 141 | 142 | 143 | #' Immune markers generated from Charoentong2017, Bindea2013, Xu2018 and classic markers 144 | #' 145 | #' A dataset containing the immune markers annotated by Charoentong2017, Bindea2013, Xu2018 146 | #' and additional classic immune inhibitors, stimulators and checkpoints. 147 | #' 148 | #' @docType data 149 | #' 150 | #' @usage data(Immune_Marker_n1293) 151 | #' 152 | #' @keywords datasets 153 | #' 154 | #' @format A vector of 1293 immune markers 155 | #' 156 | #' @references Charoentong, P., Finotello, F., Angelova, M., Mayer, C., Efremova, M., Rieder, D., ... & Trajanoski, Z. (2017). Pan-cancer immunogenomic analyses reveal genotype-immunophenotype relationships and predictors of response to checkpoint blockade. Cell reports, 18(1), 248-262. 157 | #' @references Bindea, G., Mlecnik, B., Tosolini, M., Kirilovsky, A., Waldner, M., Obenauf, A. C., ... & Galon, J. (2013). Spatiotemporal dynamics of intratumoral immune cells reveal the immune landscape in human cancer. Immunity, 39(4), 782-795. 158 | #' @references Xu, L., Deng, C., Pang, B., Zhang, X., Liu, W., Liao, G., ... & Li, X. (2018). Xu2018: a web server for resolving tumor immunophenotype profiling. Cancer research, 78(23), 6575-6580. 159 | #' 160 | #' @source Modification can be found in inst/extdata/build_Immune_Marker_n1293.R 161 | "Immune_Marker_n1293" 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | #' TCGA metastatic melanoma(SKCM06) RNA expression 171 | #' 172 | #' A dataset containing 20,501 genes from 368 metastatic melanoma samples. 173 | #' 174 | #' @docType data 175 | #' 176 | #' @usage data(SKCM06rna) 177 | #' 178 | #' @keywords datasets 179 | #' 180 | #' @format A data frame with 20501 rows and 368 variables: 181 | #' \describe{ 182 | #' \item{row}{Gene} 183 | #' \item{column}{Sample(patient) ID} 184 | #' } 185 | #' 186 | #' 187 | #' @references \url{"https://gdac.broadinstitute.org/"} 188 | #' 189 | #' @source Modification can be found in inst/extdata/build_SKCM06_RNA_info.R 190 | "SKCM06rna" 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | #' TCGA metastatic melanoma(SKCM06) clinical infomation 205 | #' 206 | #' A dataset containing survival statistic of 368 patients. 207 | #' 208 | #' @docType data 209 | #' 210 | #' @usage data(SKCM06info) 211 | #' 212 | #' @keywords datasets 213 | #' 214 | #' @format A data frame with 368 rows and 2 variables: 215 | #' \describe{ 216 | #' \item{row}{Patient ID} 217 | #' \item{column}{Clinical information, including event(death) and time(day) to event} 218 | #' } 219 | #' 220 | #' 221 | #' @references \url{"https://gdac.broadinstitute.org/"} 222 | #' 223 | #' @source Modification can be found in inst/extdata/build_SKCM06_RNA_info.R 224 | "SKCM06info" 225 | 226 | 227 | 228 | 229 | #' COX regression Results from function TimiCOX with cell type meaker annotated by Bindea2013_cancer 230 | #' 231 | #' An intermediate result generated from function TimiCOX 232 | #' that reveals the association between each marker pairs and favorable prognosis. 233 | #' 234 | #' @docType data 235 | #' 236 | #' @usage data(Bindea2013c_COX_MP_SKCM06) 237 | #' 238 | #' @keywords intermediate result 239 | #' 240 | #' @format A data frame with 110215 rows and 3 variables: 241 | #' \describe{ 242 | #' \item{Row name}{Marker pair} 243 | #' \item{HR}{Hazard.Ratio} 244 | #' \item{PV}{P-Value} 245 | #' \item{QV}{Adjust P-value} 246 | #' } 247 | #' 248 | #' 249 | #' @source intermediate result generated from function TimiCOX 250 | "Bindea2013c_COX_MP_SKCM06" 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | #' Cell Interaction Enrichment from function TimiEnrich 260 | #' with cell type meaker annotated by Bindea2013_cancer 261 | #' 262 | #' An example result of cell interaction enrichment generated from function TimiEnrich 263 | #' 264 | #' @docType data 265 | #' 266 | #' @usage data(Bindea2013c_enrich) 267 | #' 268 | #' @keywords example result 269 | #' 270 | #' 271 | #' @format a data frame of enrichment result 272 | #' generated from TimiEnrich and TimiPermFDR: 273 | #' \describe{ 274 | #' \item{Index}{A numeric vector used to specify which cell pair would be used in visualization} 275 | #' \item{Rank}{A rank of cell interaction according to Adjust. P-value} 276 | #' \item{Cell.Interaction}{Cell Interaction, e.g. Cell A_Cell B} 277 | #' \item{Favorable.Cell.Type}{In the cell pair A_B, the first cell A} 278 | #' \item{Unfavorable.Cell.Type}{In the cell pair A_B, the second cell B} 279 | #' \item{No.Total.IMGP}{The total number of marker pairs in the cell pair annotation} 280 | #' \item{No.Shared.IMGP}{The number of marker pairs shared by query pairs and annotation} 281 | #' \item{Enrichment.Ratio}{Enrichment Ratio} 282 | #' \item{P.Value}{P. value} 283 | #' \item{Adjust.P.Value}{Adjust.P.Value} 284 | #' \item{Permutation.FDR}{FDR calculated from permutation tests by shuffling cell-type markers} 285 | #' \item{Shared.IMGP}{The marker pairs shared by query pairs and annotation} 286 | #' \item{Total.IMGP}{The marker pairs in the annotation} 287 | #' } 288 | #' 289 | #' 290 | #' @source example result generated from function TimiEnrich(example/example01_Bindea2013_Cancer.R) 291 | "Bindea2013c_enrich" 292 | 293 | 294 | #' Cell Type customized for TNBC (anti-PD1/PD-L1) 295 | #' 296 | #' A dataset containing the cell type and markers customized for 297 | #' Triple-negative breast cancer (TNBC) cohorts 298 | #' treated with anti-PD1/PD-L1 therapy. 299 | #' This cell type annotation generated from single cell RNA-seq (GSE169246) 300 | #' and it includes 11 immune cell types consistent with 301 | #' the imaging mass cytometry (IMC) (zenodo.7990870). 302 | #' 303 | #' 304 | #' @docType data 305 | #' 306 | #' @usage data(CellType_TNBC_aPDL1) 307 | #' 308 | #' @keywords datasets 309 | #' 310 | #' @format A data frame with 449 rows and 3 variables: 311 | #' \describe{ 312 | #' \item{CellType}{Immune cell type} 313 | #' \item{Gene}{Marker gene of the cell type} 314 | #' \item{Dataset}{The source of the annotation} 315 | #' } 316 | #' 317 | #' @references Li C1,, HongW, Reuben A,Wang L, Anirban M, Zhang J, Cheng C. TimiGP-Response Module: Illustrates the pan-cancer immune landscape associated with response to immunotherapy. bioRxiv. (2024) 318 | #' 319 | #' @source For more details, please refer: https://github.com/CSkylarL/MSofTimiGP-Response/blob/master/Fig1/code/Fig1.script2_generate_TimiGP_markers.R 320 | "CellType_TNBC_aPDL1" 321 | 322 | 323 | 324 | #' GSE194040 TNBC chemoimmunotherapy cohort microarray expression 325 | #' 326 | #' A dataset containing 19,134 genes from 26 327 | #' Triple-negative breast cancer (TNBC) patients, 328 | #' treated with the combination of anti-PD1 immunotherapy and chemotherpay 329 | #' 330 | #' @docType data 331 | #' 332 | #' @usage data(TNBCaPD1rna) 333 | #' 334 | #' @keywords datasets 335 | #' 336 | #' @format A data frame with 19,134 rows and 26 variables: 337 | #' \describe{ 338 | #' \item{row}{Gene} 339 | #' \item{column}{Sample(patient) ID} 340 | #' } 341 | #' 342 | #' 343 | #' @references \url{"https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE194040"} 344 | #' 345 | #' @source Codes can be found in inst/extdata/build_TNBCaPD1_RNA_info.R 346 | "TNBCaPD1rna" 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | #' GSE194040 TNBC chemoimmunotherapy cohort therapy response infomation 361 | #' 362 | #' A dataset containing therapy response from 26 363 | #' Triple-negative breast cancer (TNBC) patients, 364 | #' treated with the combination of anti-PD1 immunotherapy and chemotherpay 365 | #' 366 | #' @docType data 367 | #' 368 | #' @usage data(TNBCaPD1info) 369 | #' 370 | #' @keywords datasets 371 | #' 372 | #' @format A data frame with 26 rows and 1 variables: 373 | #' \describe{ 374 | #' \item{row}{Patient ID} 375 | #' \item{column}{Response: 1=responder, 0=non-responder } 376 | #' } 377 | #' 378 | #' 379 | #' @references \url{"https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE194040"} 380 | #' 381 | #' @source Codes can be found in inst/extdata/build_TNBCaPD1_RNA_info.R 382 | "TNBCaPD1info" 383 | -------------------------------------------------------------------------------- /R/sysdata.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/R/sysdata.rda -------------------------------------------------------------------------------- /TimiGP.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | BuildType: Package 16 | PackageUseDevtools: Yes 17 | PackageInstallArgs: --no-multiarch --with-keep.source 18 | -------------------------------------------------------------------------------- /assets/images/Fig1A.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/assets/images/Fig1A.png -------------------------------------------------------------------------------- /assets/images/Fig3A.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/assets/images/Fig3A.png -------------------------------------------------------------------------------- /assets/images/Fig3B.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/assets/images/Fig3B.png -------------------------------------------------------------------------------- /assets/images/Fig3C.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/assets/images/Fig3C.png -------------------------------------------------------------------------------- /assets/images/Fig3D.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/assets/images/Fig3D.png -------------------------------------------------------------------------------- /assets/images/Fig3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/assets/images/Fig3x.png -------------------------------------------------------------------------------- /assets/images/application.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/assets/images/application.png -------------------------------------------------------------------------------- /assets/images/framework.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/assets/images/framework.png -------------------------------------------------------------------------------- /assets/images/rationale.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/assets/images/rationale.png -------------------------------------------------------------------------------- /data/Bindea2013c_COX_MP_SKCM06.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/data/Bindea2013c_COX_MP_SKCM06.rda -------------------------------------------------------------------------------- /data/Bindea2013c_enrich.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/data/Bindea2013c_enrich.rda -------------------------------------------------------------------------------- /data/CellType_Bindea2013_cancer.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/data/CellType_Bindea2013_cancer.rda -------------------------------------------------------------------------------- /data/CellType_Charoentong2017_Bindea2013_Xu2018_Immune.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/data/CellType_Charoentong2017_Bindea2013_Xu2018_Immune.rda -------------------------------------------------------------------------------- /data/CellType_Newman2015_LM22.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/data/CellType_Newman2015_LM22.rda -------------------------------------------------------------------------------- /data/CellType_TNBC_aPDL1.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/data/CellType_TNBC_aPDL1.rda -------------------------------------------------------------------------------- /data/CellType_Tirosh2016_melanoma_TME.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/data/CellType_Tirosh2016_melanoma_TME.rda -------------------------------------------------------------------------------- /data/CellType_Zheng2021_Tcell.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/data/CellType_Zheng2021_Tcell.rda -------------------------------------------------------------------------------- /data/Immune_Marker_n1293.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/data/Immune_Marker_n1293.rda -------------------------------------------------------------------------------- /data/SKCM06info.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/data/SKCM06info.rda -------------------------------------------------------------------------------- /data/SKCM06rna.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/data/SKCM06rna.rda -------------------------------------------------------------------------------- /data/TNBCaPD1info.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/data/TNBCaPD1info.rda -------------------------------------------------------------------------------- /data/TNBCaPD1rna.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSkylarL/TimiGP/9a527dd7dfe18c3155647d57c4392dad977ff13f/data/TNBCaPD1rna.rda -------------------------------------------------------------------------------- /example/example01_Bindea2013_Cancer.R: -------------------------------------------------------------------------------- 1 | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2 | # This is an example how to use TimiGP with Bindea2013_cancer annotation 3 | # Date: 03/07/2022 4 | # Chenyang Skylar Li 5 | #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 | library(TimiGP) 7 | rm(list=ls()) 8 | #A Preprocess data ############################################################ 9 | rm(list=ls()) 10 | #1. Load SCKCM06 data ---------------------------------------------------------- 11 | data("SKCM06info") 12 | head(SKCM06info) 13 | data("SKCM06rna") 14 | #2. Load cell type and marker annotation --------------------------------------- 15 | data("CellType_Bindea2013_cancer") 16 | geneset <- CellType_Bindea2013_cancer 17 | marker <- unique(geneset$Gene) 18 | #3. Preprocess: TimiCheckEvent & TimiPrePropress-------------------------------- 19 | dim(SKCM06info) 20 | info <- TimiCheckEvent(SKCM06info) 21 | dim(info) 22 | dim(SKCM06rna) 23 | 24 | rna <- TimiPrePropress(marker = marker,rna = SKCM06rna,cohort = rownames(info)) 25 | #4. Generate marker pair score: TimiGenePair ---------------------------------- 26 | mps <- TimiGenePair(rna) 27 | dim(mps) 28 | #5. Perform univariate Cox regression: TimiCOX --------------------------------- 29 | 30 | res <- TimiCOX(mps = mps,info = info,p.adj = "BH",parallel = T, core=20) 31 | mps <- res$mps 32 | cox_res <- res$cox_res 33 | 34 | Bindea2013c_COX_MP_SKCM06 <- cox_res 35 | Bindea2013c_MPS_SKCM06 <- mps 36 | 37 | # the result has been saved in data as an examples 38 | # save(Bindea2013c_COX_MP_SKCM06, file = "data/Bindea2013c_COX_MP_SKCM06.rda") 39 | 40 | 41 | #B Gene Pair and gene network ################################################## 42 | rm(list=ls()) 43 | # 6. Generate Directed Gene Network:TimiGeneNetwork --------------------------- 44 | data(Bindea2013c_COX_MP_SKCM06) 45 | cox_res <- Bindea2013c_COX_MP_SKCM06 46 | 47 | # You can use Cytoscape to visualize the network 48 | NET <- TimiGeneNetwork(resdata = cox_res,dataset = "Bindea2013_Cancer", 49 | export = F) 50 | # export =TRUE, path = "./") 51 | head(NET$network,n = 3) 52 | head(NET$node,n = 3) 53 | head(NET$edge,n = 3) 54 | 55 | 56 | #B Cell interaction and network ################################################ 57 | rm(list=ls()) 58 | # 7. Generate Cell interaction Annotation: TimiCellPair ------------------------ 59 | 60 | data(CellType_Bindea2013_cancer) 61 | geneset <- CellType_Bindea2013_cancer 62 | cell_pair <- TimiCellPair(geneset = geneset,core = 20) 63 | 64 | # 8. Select marker pairs A_B=1 associated with good prognosis ------------------ 65 | data(Bindea2013c_COX_MP_SKCM06) 66 | cox_res <- Bindea2013c_COX_MP_SKCM06 67 | GP <- rownames(cox_res)[which(cox_res$QV<0.05)] 68 | 69 | # 9. generate background: TimiBG ----------------------------------------------- 70 | background <- TimiBG(marker.pair = row.names(cox_res)) 71 | 72 | # 10. Enrichment Analysis: TimiEnrich ------------------------------------------ 73 | res <- TimiEnrich(gene = GP, background = background, 74 | geneset = cell_pair, p.adj = "BH",core=20) 75 | 76 | # Optional: Permutation to generate FDR: TimiPermFFDR -------------------------- 77 | res <- TimiPermFDR(resdata = res, geneset = geneset, gene = GP, 78 | background = background, niter = 100, core = 20) 79 | 80 | # This has been saved to data as an example 81 | #Bindea2013c_enrich <- res 82 | #save(Bindea2013c_enrich,file = "data/Bindea2013c_enrich.rda") 83 | 84 | # 11. Generate Directed Cell Network:TimiCellNetwork -------------------------- 85 | # You can use Cytoscape to visualize the network 86 | rm(list=ls()) 87 | data("Bindea2013c_enrich") 88 | res <- Bindea2013c_enrich 89 | NET <- TimiCellNetwork(resdata = res,dataset = "Bindea2013_Cancer", 90 | export = F) 91 | # export =TRUE, path = "./") 92 | head(NET$network,n = 3) 93 | head(NET$node,n = 3) 94 | head(NET$edge,n = 3) 95 | 96 | # You can also use stricter condition, e.g. Permutation.FDR 97 | NET <- TimiCellNetwork(resdata = res,dataset = "Bindea2013_Cancer", 98 | condition = "Permutation.FDR", cutoff = 0.2, export = F) 99 | # C Visualization############################################################### 100 | 101 | # 12. Visualization: Dot plot of selected cell interaction: TimiDotplot--------- 102 | rm(list=ls()) 103 | data("Bindea2013c_enrich") 104 | res <- Bindea2013c_enrich 105 | p <- TimiDotplot(resdata = res,select = c(1:10)) 106 | p 107 | 108 | # 13. Visualization: Chord Diagram of inter-cell interaction: TimiCellChord----- 109 | rm(list=ls()) 110 | data("Bindea2013c_enrich") 111 | res <- Bindea2013c_enrich 112 | # Cell Chord Diagram 113 | TimiCellChord(resdata = res,dataset = "Bindea2013_Cancer") 114 | # You can also use stricter condition, e.g. Permutation.FDR 115 | # TimiCellChord(resdata = res,dataset = "Bindea2013_Cancer", 116 | # condition = "Permutation.FDR", cutoff = 0.2) 117 | # Chord Diagram of marker pairs in seltect cell interaction 118 | TimiGeneChord(resdata = res,select = 1) 119 | 120 | # 14. Calculate favorability score: TimiFS ------------------------------------- 121 | # Visualization: TimiFSBar 122 | rm(list=ls()) 123 | data("Bindea2013c_enrich") 124 | res <- Bindea2013c_enrich 125 | # Calculate 126 | score <- TimiFS(res) 127 | # You can also use stricter condition, e.g. Permutation.FDR 128 | # score <- TimiFS(res,condition = "Permutation.FDR", cutoff = 0.2) 129 | head(score) 130 | # Visualization 131 | p <- TimiFSBar(score) 132 | p 133 | p1 <- TimiFSBar(score,select = c(1:5,(nrow(score)-2):nrow(score))) 134 | p1 135 | -------------------------------------------------------------------------------- /example/example02_Charoentong2017_Bindea2013_Xu2018_Immune.R: -------------------------------------------------------------------------------- 1 | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2 | # This is an example how to use TimiGP 3 | # with Charoentong2017_Bindea2013_Xu2018 Immune annotation 4 | # Date: 03/07/2022 5 | # Chenyang Skylar Li 6 | #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | library(TimiGP) 8 | rm(list=ls()) 9 | #A Preprocess data ############################################################# 10 | rm(list=ls()) 11 | #1. Load SCKCM06 data ---------------------------------------------------------- 12 | data("SKCM06info") 13 | head(SKCM06info) 14 | data("SKCM06rna") 15 | #2. Load cell type and marker annotation --------------------------------------- 16 | data(CellType_Charoentong2017_Bindea2013_Xu2018_Immune) 17 | geneset <- CellType_Charoentong2017_Bindea2013_Xu2018_Immune 18 | 19 | #3. Preprocess: TimiCheckEvent & TimiPrePropress-------------------------------- 20 | dim(SKCM06info) 21 | info <- TimiCheckEvent(SKCM06info) 22 | dim(info) 23 | dim(SKCM06rna) 24 | 25 | t <- table(geneset$Dataset) 26 | t 27 | mps <- list() 28 | cox_res <- list() 29 | for (i in 1:3) { 30 | cat("\n",names(t)[i]) 31 | se <- which(geneset$Dataset == names(t)[i]) 32 | marker <- unique(geneset$Gene[se]) 33 | rna <- TimiPrePropress(marker = marker,rna = SKCM06rna, 34 | cohort = rownames(info)) 35 | #4. Generate marker pair score: TimiGenePair -------------------------------- 36 | mps_tmp <- TimiGenePair(rna) 37 | dim(mps) 38 | #5. Perform univariate Cox regression: TimiCOX ------------------------------- 39 | 40 | res<- TimiCOX(mps = mps_tmp,info = info,p.adj = "BH",parallel = T, core=20) 41 | mps[[ names(t)[i] ]] <- res$mps 42 | cox_res[[names(t)[i]]] <- res$cox_res 43 | } 44 | Immune3_COX_MP_SKCM06 <- cox_res 45 | Immune3_MPS_SKCM06 <- mps 46 | 47 | # save(Immune3_COX_MP_SKCM06, file = "~/Mypackage/MSofTimiGP/Fig4/Immune3_COX_MP_SKCM06.rda") 48 | # The file is saved to the manuscript code repo: https://github.com/CSkylarL/MSofTimiGP 49 | # You can find it here: 50 | # https://github.com/CSkylarL/MSofTimiGP/blob/master/Fig4/Immune3_COX_MP_SKCM06.rda 51 | 52 | 53 | #B Gene Pair and gene network ################################################## 54 | rm(list=ls()) 55 | # 6. Generate Directed Gene Network:TimiGeneNetwork --------------------------- 56 | data(Immune3_COX_MP_SKCM06) 57 | cox_res <- Immune3_COX_MP_SKCM06 58 | t <- names(cox_res) 59 | # You can use Cytoscape to visualize the network 60 | NET <- list() 61 | for (i in 1:3){ 62 | NET <- TimiGeneNetwork(resdata = cox_res[[t[i]]],dataset = "Immune3", 63 | export = F) 64 | # export =TRUE, path = "./") 65 | } 66 | 67 | 68 | #B Cell interaction and network ################################################ 69 | rm(list=ls()) 70 | 71 | data("CellType_Charoentong2017_Bindea2013_Xu2018_Immune") 72 | geneset <- CellType_Charoentong2017_Bindea2013_Xu2018_Immune 73 | 74 | # There are 3 genesets, find cell interaction seperately 75 | data(Immune3_COX_MP_SKCM06) 76 | cox_res <- Immune3_COX_MP_SKCM06 77 | t <- names(cox_res) 78 | res <- list() 79 | for (i in 1:3) { 80 | cat("\n",t[i]) 81 | # 7. Select marker pairs A_B=1 associated with good prognosis ---------------- 82 | GP <- rownames(cox_res[[t[i]]])[which(cox_res[[t[i]]]$QV<0.05)] 83 | 84 | # 8. generate background: TimiBG ---- 85 | background <- TimiBG(marker.pair = row.names(cox_res[[t[i]]])) 86 | 87 | 88 | # 9. Generate Cell Interaction Annotation: TimiCellPair ---------------------- 89 | # “CellType_Charoentong2017_Bindea2013_Xu2018_Immune” 90 | # contains three different immune cell-type annotations. 91 | # so we used "dataset" parameter to specify the dataset name. 92 | cell_pair <- TimiCellPair(geneset = geneset, dataset= t[i],core = 20) 93 | # 10. Enrichment Analysis: TimiEnrich ---- 94 | res[[t[i]]] <- TimiEnrich(gene = GP, background = background, 95 | geneset = cell_pair, p.adj = "BH",core=20) 96 | } 97 | 98 | 99 | # 11. Generate Directed Cell Network:TimiCellNetwork -------------------------- 100 | # You can use Cytoscape to visualize the network 101 | NET <- list() 102 | for (i in 1:3){ 103 | NET <- TimiCellNetwork(resdata = res[[t[i]]],dataset = t[i],export = F) 104 | # export =TRUE, path = "./") 105 | } 106 | 107 | 108 | # 12. Visualization: Dot plot of selected cell interactions: TimiDotplot------- 109 | 110 | p1 <- TimiDotplot(resdata = res$Charoentong2017,select = c(1:10)) 111 | p1 112 | 113 | p2 <- TimiDotplot(resdata = res$Bindea2013,select = c(1:10)) 114 | p2 115 | 116 | p3 <- TimiDotplot(resdata = res$Xu2018,select = c(1:10)) 117 | p3 118 | # 13. Visualization: Chord Diagram of inter-cell interaction: TimiCellChord----- 119 | 120 | # Cell Chord Diagram 121 | TimiCellChord(resdata = res$Charoentong2017,dataset = "Charoentong2017") 122 | TimiCellChord(resdata = res$Bindea2013,dataset = "Bindea2013") 123 | TimiCellChord(resdata = res$Xu2018,dataset = "Xu2018") 124 | # Chord Diagram of marker pairs in seltect cell interaction 125 | TimiGeneChord(resdata = res$Charoentong2017,select = 1) 126 | TimiGeneChord(resdata = res$Bindea2013,select = 1) 127 | TimiGeneChord(resdata = res$Xu2018,select = 1) 128 | # 14. Calculate favorability score: TimiFS ------------------------------------- 129 | # Visualization: TimiFSBar 130 | # Calculate 131 | score1 <- TimiFS(res$Charoentong2017) 132 | score2 <- TimiFS(res$Bindea2013) 133 | score3 <- TimiFS(res$Xu2018) 134 | head(score) 135 | # Visualization 136 | p1 <- TimiFSBar(score1) 137 | p1 138 | 139 | p2 <- TimiFSBar(score2) 140 | p2 141 | 142 | p3 <- TimiFSBar(score3) 143 | p3 144 | -------------------------------------------------------------------------------- /example/example03_Newman2015_LM22.R: -------------------------------------------------------------------------------- 1 | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2 | # This is an example how to use TimiGP with Newman2015_LM22 annotation 3 | # Date: 03/07/2022 4 | # Chenyang Skylar Li 5 | #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 | library(TimiGP) 7 | rm(list=ls()) 8 | #A Preprocess data ############################################################ 9 | rm(list=ls()) 10 | #1. Load SCKCM06 data ---------------------------------------------------------- 11 | data("SKCM06info") 12 | head(SKCM06info) 13 | data("SKCM06rna") 14 | #2. Load cell type and marker annotation --------------------------------------- 15 | data("CellType_Newman2015_LM22") 16 | geneset <- CellType_Newman2015_LM22 17 | marker <- unique(geneset$Gene) 18 | #3. Preprocess: TimiCheckEvent & TimiPrePropress-------------------------------- 19 | dim(SKCM06info) 20 | info <- TimiCheckEvent(SKCM06info) 21 | dim(info) 22 | dim(SKCM06rna) 23 | 24 | rna <- TimiPrePropress(marker = marker,rna = SKCM06rna,cohort = rownames(info)) 25 | #4. Generate marker pair score: TimiGenePair ---------------------------------- 26 | mps <- TimiGenePair(rna) 27 | dim(mps) 28 | #5. Perform univariate Cox regression: TimiCOX --------------------------------- 29 | 30 | res <- TimiCOX(mps = mps,info = info,p.adj = "BH",parallel = T, core=20) 31 | mps <- res$mps 32 | cox_res <- res$cox_res 33 | 34 | Newman2015_COX_MP_SKCM06 <- cox_res 35 | Newman2015_MPS_SKCM06 <- mps 36 | 37 | 38 | #save(Newman2015_COX_MP_SKCM06, file = "~/Mypackage/MSofTimiGP/Fig4/Newman2015//Newman2015_COX_MP_SKCM06.rda") 39 | # The file is saved to the manuscript code repo: https://github.com/CSkylarL/MSofTimiGP 40 | # You can find it here: 41 | # https://github.com/CSkylarL/MSofTimiGP/blob/master/Fig4/Newman2015/Newman2015_COX_MP_SKCM06.rda 42 | 43 | #B Gene Pair and gene network ################################################## 44 | rm(list=ls()) 45 | # 6. Generate Directed Gene Network:TimiGeneNetwork --------------------------- 46 | data(Newman2015_COX_MP_SKCM06) 47 | cox_res <- Newman2015_COX_MP_SKCM06 48 | 49 | # You can use Cytoscape to visualize the network 50 | NET <- TimiGeneNetwork(resdata = cox_res,dataset = "Newman2015", 51 | export = F) 52 | # export =TRUE, path = "./") 53 | head(NET$network,n = 3) 54 | head(NET$node,n = 3) 55 | head(NET$edge,n = 3) 56 | 57 | 58 | #B Cell interaction and network ################################################ 59 | rm(list=ls()) 60 | # 7. Generate Cell interaction Annotation: TimiCellPair ------------------------ 61 | 62 | data(CellType_Newman2015_LM22) 63 | geneset <- CellType_Newman2015_LM22 64 | cell_pair <- TimiCellPair(geneset = geneset,core = 20) 65 | 66 | # 8. Select marker pairs A_B=1 associated with good prognosis ------------------ 67 | data(Newman2015_COX_MP_SKCM06) 68 | cox_res <- Newman2015_COX_MP_SKCM06 69 | GP <- rownames(cox_res)[which(cox_res$QV<0.05)] 70 | 71 | # 9. generate background: TimiBG ----------------------------------------------- 72 | background <- TimiBG(marker.pair = row.names(cox_res)) 73 | 74 | # 10. Enrichment Analysis: TimiEnrich ------------------------------------------ 75 | res <- TimiEnrich(gene = GP, background = background, 76 | geneset = cell_pair, p.adj = "BH",core=20) 77 | 78 | # 11. Generate Directed Cell Network:TimiCellNetwork -------------------------- 79 | # You can use Cytoscape to visualize the network 80 | NET <- TimiCellNetwork(resdata = res,dataset = "Newman2015", 81 | export = F) 82 | # export =TRUE, path = "./") 83 | head(NET$network,n = 3) 84 | head(NET$node,n = 3) 85 | head(NET$edge,n = 3) 86 | 87 | # C Visualization############################################################### 88 | 89 | # 12. Visualization: Dot plot of selected cell interaction: TimiDotplot--------- 90 | p <- TimiDotplot(resdata = res,select = c(1:10)) 91 | p 92 | 93 | # 13. Visualization: Chord Diagram of inter-cell interaction: TimiCellChord----- 94 | 95 | # Cell Chord Diagram 96 | TimiCellChord(resdata = res,dataset = "Newman2015") 97 | # Chord Diagram of marker pairs in seltect cell interaction 98 | TimiGeneChord(resdata = res,select = 1) 99 | 100 | # 14. Calculate favorability score: TimiFS ------------------------------------- 101 | # Visualization: TimiFSBar 102 | # Calculate 103 | score <- TimiFS(res) 104 | head(score) 105 | # Visualization 106 | p <- TimiFSBar(score) 107 | p 108 | p1 <- TimiFSBar(score,select = c(1:5,(nrow(score)-2):nrow(score))) 109 | p1 110 | -------------------------------------------------------------------------------- /example/example04_Tirosh2016_melanoma_TME.R: -------------------------------------------------------------------------------- 1 | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2 | # This is an example how to use TimiGP with Tirosh2016 melanoma_TME annotation 3 | # Date: 03/07/2022 4 | # Chenyang Skylar Li 5 | #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 | library(TimiGP) 7 | rm(list=ls()) 8 | #A Preprocess data ############################################################# 9 | rm(list=ls()) 10 | #1. Load SCKCM06 data ---------------------------------------------------------- 11 | data("SKCM06info") 12 | head(SKCM06info) 13 | data("SKCM06rna") 14 | #2. Load cell type and marker annotation --------------------------------------- 15 | data("CellType_Tirosh2016_melanoma_TME") 16 | geneset <- CellType_Tirosh2016_melanoma_TME 17 | marker <- unique(geneset$Gene) 18 | #3. Preprocess: TimiCheckEvent & TimiPrePropress 19 | dim(SKCM06info) 20 | info <- TimiCheckEvent(SKCM06info) 21 | dim(info) 22 | dim(SKCM06rna) 23 | 24 | rna <- TimiPrePropress(marker = marker,rna = SKCM06rna,cohort = rownames(info)) 25 | 26 | 27 | #4. Generate marker pair score: TimiGenePair ---------------------------------- 28 | mps <- TimiGenePair(rna) 29 | dim(mps) 30 | #5. Perform univariate Cox regression: TimiCOX --------------------------------- 31 | 32 | res <- TimiCOX(mps = mps,info = info,p.adj = "BH",parallel = T, core=20) 33 | mps <- res$mps 34 | cox_res <- res$cox_res 35 | 36 | melanoma_TME_COX_MP_SKCM06 <- cox_res 37 | melanoma_TME_MPS_SKCM06 <- mps 38 | 39 | #save(melanoma_TME_COX_MP_SKCM06, file = "~/Mypackage/MSofTimiGP/Fig6/Tirosh2016_melanoma_TME/melanoma_TME_COX_MP_SKCM06.rda") 40 | # The file is saved to the manuscript code repo: https://github.com/CSkylarL/MSofTimiGP 41 | # You can find it here: 42 | # https://github.com/CSkylarL/MSofTimiGP/blob/master/Fig6/Tirosh2016_melanoma_TME/melanoma_TME_COX_MP_SKCM06.rda 43 | 44 | #B Gene Pair and gene network ################################################## 45 | rm(list=ls()) 46 | # 6. Generate Directed Gene Network:TimiGeneNetwork --------------------------- 47 | data(melanoma_TME_COX_MP_SKCM06) 48 | cox_res <- melanoma_TME_COX_MP_SKCM06 49 | 50 | # You can use Cytoscape to visualize the network 51 | NET <- TimiGeneNetwork(resdata = cox_res,dataset = "Tirosh2016", 52 | export = F) 53 | # export =TRUE, path = "./") 54 | head(NET$network,n = 3) 55 | head(NET$node,n = 3) 56 | head(NET$edge,n = 3) 57 | 58 | 59 | #B Cell interaction and network ################################################ 60 | rm(list=ls()) 61 | # 7. Generate Cell Interaction Annotation: TimiCellPair ------------------------ 62 | 63 | data("CellType_Tirosh2016_melanoma_TME") 64 | geneset <- CellType_Tirosh2016_melanoma_TME 65 | 66 | cell_pair <- TimiCellPair(geneset = geneset,core = 20) 67 | 68 | # 8. Select marker pairs A_B=1 associated with good prognosis ------------------ 69 | data(melanoma_TME_COX_MP_SKCM06) 70 | cox_res <- melanoma_TME_COX_MP_SKCM06 71 | GP <- rownames(cox_res)[which(cox_res$QV<0.05)] 72 | 73 | # 9. generate background: TimiBG ---- 74 | background <- TimiBG(marker.pair = row.names(cox_res)) 75 | 76 | # 10. Enrichment Analysis: TimiEnrich ---- 77 | res <- TimiEnrich(gene = GP, background = background, 78 | geneset = cell_pair, p.adj = "BH",core=20) 79 | 80 | # 11. Generate Directed Cell Network:TimiCellNetwork ---- 81 | # You can use Cytoscape to visualize the network 82 | NET <- TimiCellNetwork(resdata = res,dataset = "Tirosh2016", 83 | export = F) 84 | # export =TRUE, path = "./") 85 | 86 | # 12. Visualization: Dot plot of selected cell interaction: TimiDotplot--------- 87 | 88 | p <- TimiDotplot(resdata = res,select = c(1:10)) 89 | p 90 | 91 | # 13. Visualization: Chord Diagram of functional interaction: TimiCellChord----- 92 | 93 | # Cell Chord Diagram 94 | TimiCellChord(resdata = res,dataset = "Tirosh2016") 95 | # Chord Diagram of marker pairs in seltect cell interaction 96 | TimiGeneChord(resdata = res,select = 1) 97 | 98 | # 13. Calculate favorability score: TimiFS ------------------------------------- 99 | # Visualization: TimiFSBar 100 | # Calculate 101 | score <- TimiFS(res) 102 | head(score) 103 | # Visualization 104 | p <- TimiFSBar(score) 105 | p 106 | -------------------------------------------------------------------------------- /example/example05_Zheng2021_Tcell.R: -------------------------------------------------------------------------------- 1 | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2 | # This is an example how to use TimiGP with Zheng2021 Tcell annotation 3 | # Date: 03/07/2022 4 | # Chenyang Skylar Li 5 | #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 | library(TimiGP) 7 | rm(list=ls()) 8 | #A Preprocess data ############################################################# 9 | rm(list=ls()) 10 | #1. Load SCKCM06 data ---------------------------------------------------------- 11 | data("SKCM06info") 12 | head(SKCM06info) 13 | data("SKCM06rna") 14 | #2. Load cell type and marker annotation --------------------------------------- 15 | data("CellType_Zheng2021_Tcell") 16 | geneset <- CellType_Zheng2021_Tcell 17 | marker <- unique(geneset$Gene) 18 | #3. Preprocess: TimiCheckEvent & TimiPrePropress 19 | dim(SKCM06info) 20 | info <- TimiCheckEvent(SKCM06info) 21 | dim(info) 22 | dim(SKCM06rna) 23 | 24 | rna <- TimiPrePropress(marker = marker,rna = SKCM06rna,cohort = rownames(info)) 25 | #4. Generate marker pair score: TimiGenePair ---------------------------------- 26 | mps <- TimiGenePair(rna) 27 | dim(mps) 28 | #5. Perform univariate Cox regression: TimiCOX --------------------------------- 29 | 30 | res <- TimiCOX(mps = mps,info = info,p.adj = "BH",parallel = T, core=20) 31 | mps <- res$mps 32 | cox_res <- res$cox_res 33 | 34 | Tcell_COX_MP_SKCM06 <- cox_res 35 | Tcell_MPS_SKCM06 <- mps 36 | 37 | 38 | #save(Tcell_COX_MP_SKCM06, file = "~/Mypackage/MSofTimiGP/Fig6/Zheng2021_Tcell/Tcell_COX_MP_SKCM06.rda") 39 | # The file is saved to the manuscript code repo: https://github.com/CSkylarL/MSofTimiGP 40 | # You can find it here: 41 | # https://github.com/CSkylarL/MSofTimiGP/blob/master/Fig6/Zheng2021_Tcell/Tcell_COX_MP_SKCM06.rda 42 | 43 | 44 | #B Gene Pair and gene network ################################################## 45 | rm(list=ls()) 46 | # 6. Generate Directed Gene Network:TimiGeneNetwork ---- 47 | data(Tcell_COX_MP_SKCM06) 48 | cox_res <- Tcell_COX_MP_SKCM06 49 | 50 | # You can use Cytoscape to visualize the network 51 | NET <- TimiGeneNetwork(resdata = cox_res,dataset = "Zheng2021", 52 | export = F) 53 | # export =TRUE, path = "./") 54 | head(NET$network,n = 3) 55 | head(NET$node,n = 3) 56 | head(NET$edge,n = 3) 57 | 58 | 59 | #B Cell interaction and network ################################################ 60 | rm(list=ls()) 61 | # 7. Generate Cell Interaction Annotation: TimiCellPair ------------------------ 62 | 63 | data("CellType_Zheng2021_Tcell") 64 | geneset <- CellType_Zheng2021_Tcell 65 | cell_pair <- TimiCellPair(geneset = geneset,core = 20) 66 | 67 | # 8. Select marker pairs A_B=1 associated with good prognosis ------------------ 68 | data(Tcell_COX_MP_SKCM06) 69 | cox_res <- Tcell_COX_MP_SKCM06 70 | GP <- rownames(cox_res)[which(cox_res$QV<0.05)] 71 | 72 | # 9. generate background: TimiBG ---- 73 | background <- TimiBG(marker.pair = row.names(cox_res)) 74 | 75 | # 10. Enrichment Analysis: TimiEnrich ---- 76 | res <- TimiEnrich(gene = GP, background = background, 77 | geneset = cell_pair, p.adj = "BH",core=20) 78 | 79 | # 11. Generate Directed Cell Network:TimiCellNetwork ---- 80 | # You can use Cytoscape to visualize the network 81 | NET <- TimiCellNetwork(resdata = res,dataset = "Zheng2021", 82 | export = F) 83 | # export =TRUE, path = "./") 84 | 85 | # 12. Visualization: Dot plot of selected cell interaction: TimiDotplot--------- 86 | 87 | p <- TimiDotplot(resdata = res,select = c(1:10)) 88 | p 89 | 90 | # 13. Visualization: Chord Diagram of inter-cell interaction: TimiCellChord----- 91 | 92 | 93 | # Cell Chord Diagram 94 | TimiCellChord(resdata = res,dataset = "Zheng2021") 95 | # Chord Diagram of marker pairs in seltect cell interaction 96 | TimiGeneChord(resdata = res,select = 1) 97 | 98 | # 134 Calculate favorability score: TimiFS ------------------------------------- 99 | # Visualization: TimiFSBar 100 | # Calculate 101 | score <- TimiFS(res) 102 | head(score) 103 | # Visualization 104 | p <- TimiFSBar(score) 105 | p 106 | -------------------------------------------------------------------------------- /example/example06_Bindea2013_Cancer_continuous_pair.R: -------------------------------------------------------------------------------- 1 | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2 | # This is an example how to use TimiGP to capture continuous relations 3 | # between gene pairs with Bindea2013_cancer annotation, 4 | # which is more sensitive compared to default logical relation. 5 | # Date: 04/03/2023 6 | # Chenyang Skylar Li 7 | #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 8 | library(TimiGP) 9 | rm(list=ls()) 10 | #A Preprocess data ############################################################ 11 | rm(list=ls()) 12 | #1. Load SCKCM06 data ---------------------------------------------------------- 13 | data("SKCM06info") 14 | head(SKCM06info) 15 | data("SKCM06rna") 16 | #2. Load cell type and marker annotation --------------------------------------- 17 | data("CellType_Bindea2013_cancer") 18 | geneset <- CellType_Bindea2013_cancer 19 | marker <- unique(geneset$Gene) 20 | #3. Preprocess: TimiCheckEvent & TimiPrePropress-------------------------------- 21 | dim(SKCM06info) 22 | info <- TimiCheckEvent(SKCM06info) 23 | dim(info) 24 | dim(SKCM06rna) 25 | 26 | # Note: set `GMNorm = F` to avoid default gene-wise median normalization 27 | rna <- TimiPrePropress(marker = marker,rna = SKCM06rna, 28 | cohort = rownames(info),log = T,GMNorm = F) 29 | 30 | #4. Generate marker pair score: TimiGenePair ---------------------------------- 31 | # Note: set `cont = T` to to capture continuous relation (expression ratio) 32 | mps <- TimiGenePair(rna, cont = T) 33 | dim(mps) 34 | #5. Perform univariate Cox regression: TimiCOX --------------------------------- 35 | 36 | res <- TimiCOX(mps = mps,info = info,p.adj = "BH",parallel = T, core=20) 37 | mps <- res$mps 38 | cox_res <- res$cox_res 39 | 40 | Bindea2013c_COX_MP_SKCM06_CONT <- cox_res 41 | Bindea2013c_MPS_SKCM06_CONT <- mps 42 | 43 | # This step takes about 5-10 min, please be patient 44 | 45 | 46 | #B Gene Pair and gene network ################################################## 47 | # 6. Generate Directed Gene Network:TimiGeneNetwork --------------------------- 48 | 49 | # You can use Cytoscape to visualize the network 50 | NET <- TimiGeneNetwork(resdata = cox_res,dataset = "Bindea2013_Cancer", 51 | export = F) 52 | # export =TRUE, path = "./") 53 | head(NET$network,n = 3) 54 | head(NET$node,n = 3) 55 | head(NET$edge,n = 3) 56 | 57 | 58 | #B Cell interaction and network ################################################ 59 | # 7. Generate Cell interaction Annotation: TimiCellPair ------------------------ 60 | 61 | data(CellType_Bindea2013_cancer) 62 | geneset <- CellType_Bindea2013_cancer 63 | cell_pair <- TimiCellPair(geneset = geneset,core = 20) 64 | 65 | # 8. Select marker pairs A_B=1 associated with good prognosis ------------------ 66 | GP <- rownames(cox_res)[which(cox_res$QV<0.05)] 67 | 68 | # 9. generate background: TimiBG ----------------------------------------------- 69 | background <- TimiBG(marker.pair = row.names(cox_res)) 70 | 71 | # 10. Enrichment Analysis: TimiEnrich ------------------------------------------ 72 | res <- TimiEnrich(gene = GP, background = background, 73 | geneset = cell_pair, p.adj = "BH",core=20) 74 | 75 | # 11. Generate Directed Cell Network:TimiCellNetwork -------------------------- 76 | # You can use Cytoscape to visualize the network 77 | 78 | NET <- TimiCellNetwork(resdata = res,dataset = "Bindea2013_Cancer", 79 | export = F) 80 | # export =TRUE, path = "./") 81 | head(NET$network,n = 3) 82 | head(NET$node,n = 3) 83 | head(NET$edge,n = 3) 84 | 85 | # C Visualization############################################################### 86 | 87 | # 12. Visualization: Dot plot of selected cell interaction: TimiDotplot--------- 88 | 89 | p <- TimiDotplot(resdata = res,select = c(1:10)) 90 | p 91 | 92 | # 13. Visualization: Chord Diagram of inter-cell interaction: TimiCellChord----- 93 | 94 | # Cell Chord Diagram 95 | TimiCellChord(resdata = res,dataset = "Bindea2013_Cancer") 96 | # Chord Diagram of marker pairs in seltect cell interaction 97 | TimiGeneChord(resdata = res,select = 1) 98 | 99 | # 14. Calculate favorability score: TimiFS ------------------------------------- 100 | # Visualization: TimiFSBar 101 | # Calculate 102 | score <- TimiFS(res) 103 | head(score) 104 | # Visualization 105 | p <- TimiFSBar(score) 106 | p 107 | 108 | -------------------------------------------------------------------------------- /example/example07_customized_TNBC_Response.R: -------------------------------------------------------------------------------- 1 | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2 | # This is an example how to use TimiGP-Response 3 | # Date: 06/05/2023 4 | # Author: Chenyang Skylar Li 5 | #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 | # Clear all variables 7 | rm(list=ls()) 8 | # load the TimiGP package 9 | library(TimiGP) 10 | #A Preprocess data ############################################################ 11 | #1. Load example data ---------------------------------------------------------- 12 | # This is example data was generated from GSE194040, 13 | # including 26 Triple-negative breast cancer (TNBC) patients 14 | # treated with the combination of anti-PD1 immunotherapy and chemotherpay 15 | # Please refer to ./inst/extdata/build_TNBCaPD1_RNA_info.R for more details 16 | data(TNBCaPD1info) 17 | head(TNBCaPD1info) 18 | # 1=Responder; 0=Non-responder 19 | # Response 20 | # X111038 0 21 | # X115638 0 22 | # X116603 0 23 | # X153327 1 24 | # X178649 1 25 | # X196024 0 26 | 27 | data(TNBCaPD1rna) 28 | #2. Load cell type and marker annotation --------------------------------------- 29 | # The cell type annotation is customized for TNBC (anti-PD1/PD-L1) 30 | # from single cell RNA-seq. 31 | # For more details, please refer: 32 | # https://github.com/CSkylarL/MSofTimiGP-Response/blob/master/Fig1/code/Fig1.script2_generate_TimiGP_markers.R 33 | 34 | data("CellType_TNBC_aPDL1") 35 | geneset <- CellType_TNBC_aPDL1 36 | marker <- unique(geneset$Gene) 37 | 38 | #3. Preprocess: TimiPrePropress------------------------------------------------ 39 | info <- TNBCaPD1info 40 | table(info) 41 | 42 | # Response 43 | # 0 1 44 | # 13 13 45 | 46 | # Automatically check if the expression has been log tranformed or not 47 | rna <- TNBCaPD1rna 48 | if (max(rna,na.rm = T) < 100){ 49 | log = FALSE 50 | } else { 51 | log = TRUE 52 | } 53 | cat("\n", max(rna,na.rm = T)," log = ", log,"\n") 54 | # 18.565 log = FALSE 55 | 56 | rna <- TimiPrePropress(marker = marker, cohort = rownames(info), 57 | log = log, GMNorm = T, rna = rna) 58 | #4. Generate marker pair score: TimiGenePair ---------------------------------- 59 | mps <- TimiGenePair(rna) 60 | dim(mps) 61 | #5. Perform Fisher Test: TimiFisher -------------------------------------------- 62 | # Note: This step is unique for the TimiGP-Response 63 | # If you have >1000 markers, 64 | # you can set `parallel = T, core=10` to enable parallel computiong 65 | 66 | res <- TimiFisher(mps = mps,info = info,p.adj = "BH") 67 | 68 | mps <- res$mps 69 | fisher_res <- res$fisher_res 70 | 71 | #B Gene Pair and gene network ################################################## 72 | # 6. Generate Directed Gene Network:TimiGeneNetwork --------------------------- 73 | 74 | # You can use Cytoscape to visualize the network 75 | NET <- TimiGeneNetwork(resdata = fisher_res, 76 | dataset = "Other", 77 | geneset = geneset, 78 | condition = "PV", 79 | cutoff = 0.05, 80 | export = F) 81 | # If you want to export the files, 82 | # Please set `export =TRUE, path = "./"` 83 | head(NET$network,n = 3) 84 | head(NET$node,n = 3) 85 | head(NET$edge,n = 3) 86 | 87 | 88 | #B Cell interaction and network ################################################ 89 | # 7. Generate Cell interaction Annotation: TimiCellPair ------------------------ 90 | cell_pair <- TimiCellPair(geneset = geneset,core = 20) 91 | 92 | # 8. Select marker pairs A_B=1 associated with responders ------------------ 93 | 94 | GP <- fisher_res %>% filter(PV < 0.05) %>% rownames() 95 | 96 | # 9. generate background: TimiBG ----------------------------------------------- 97 | background <- TimiBG(marker.pair = row.names(fisher_res)) 98 | 99 | # 10. Enrichment Analysis: TimiEnrich ------------------------------------------ 100 | res <- TimiEnrich(gene = GP, background = background, 101 | geneset = cell_pair, p.adj = "BH",core=20) 102 | 103 | # Optional: Permutation to generate FDR: TimiPermFFDR -------------------------- 104 | res <- TimiPermFDR(resdata = res, geneset = geneset, gene = GP, 105 | background = background, niter = 100, core = 20) 106 | 107 | # 11. Generate Directed Cell Network:TimiCellNetwork -------------------------- 108 | # define cell-cell interaction ------------------------------------------- 109 | CI_condition <- "Adjust.P.Value" 110 | CI_cutoff <- 0.05 111 | cat("CI_cutoff: ", CI_condition, " < ", 112 | CI_cutoff, " : #",sum(res[,CI_condition] < CI_cutoff)) 113 | # CI_cutoff: Adjust.P.Value < 0.05 : # 49 114 | 115 | # settings for visualization -------------------------------------------------- 116 | # Cell names 117 | cell <- c("CD20+B" , "CD79a+Plasma", 118 | "CD4+TCF1+T" ,"CD4+PD1+T" ,"Treg" , 119 | "CD8+TCF1+T" ,"CD8+GZMB+T" ,"CD8+PD1+Tex" , 120 | "CD56+NK" ,"cDC" , "pDC" , 121 | "M1" , "M2" , 122 | "Mast" ) 123 | 124 | # Cell group 125 | group <- c(rep("B",2), 126 | rep("CD4T", 3), 127 | rep("CD8T", 3), 128 | "NK", 129 | rep("DC", 2), 130 | rep("Mac", 2), 131 | "Mast") 132 | # Cell color 133 | color <- c("#66c2a4","#238b45", 134 | "#bcbddc","#807dba","#54278f", 135 | "#fa9fb5","#dd3497","#7a0177", 136 | "#2b8cbe", 137 | "#225ea8","#081d58", 138 | "#feb24c","#ec7014", 139 | "#e31a1c") 140 | names(group) <- cell 141 | names(color) <- cell 142 | 143 | # You can use Cytoscape to visualize the network 144 | 145 | NET <- TimiCellNetwork(resdata = res, 146 | condition = CI_condition, 147 | cutoff = CI_cutoff, 148 | geneset = geneset, 149 | dataset = "Other", 150 | group = group, 151 | export =F) 152 | # If you want to export the files, 153 | # Please set `export =TRUE, path = "./"` 154 | head(NET$network,n = 3) 155 | head(NET$node,n = 3) 156 | head(NET$edge,n = 3) 157 | 158 | # C Visualization############################################################### 159 | 160 | # 12. Visualization: Dot plot of selected cell interaction: TimiDotplot--------- 161 | nn <- min(sum(res[,CI_condition] < CI_cutoff),10) 162 | p <- TimiDotplot(resdata = res, 163 | condition = CI_condition, 164 | cutoff = CI_cutoff, 165 | select = c(1:nn)) 166 | p 167 | 168 | # 13. Visualization: Chord Diagram of inter-cell interaction: TimiCellChord----- 169 | TimiCellChord(resdata = res, 170 | dataset = "Other",group = group,color = color, 171 | condition = CI_condition, cutoff = CI_cutoff) 172 | # Chord Diagram of marker pairs in seltect cell interaction 173 | TimiGeneChord(resdata = res,select = 1) 174 | 175 | # 14. Calculate favorability score: TimiFS ------------------------------------- 176 | # Visualization: TimiFSBar 177 | score <- TimiFS(res,condition = CI_condition,cutoff = CI_cutoff) 178 | head(score) 179 | # Visualization 180 | p <- TimiFSBar(score) 181 | p 182 | 183 | # This is an example code modified from 184 | # https://github.com/CSkylarL/MSofTimiGP-Response/blob/master/Fig1/code/Fig1.script3_customized_TimiGP_response_for_TNBC.R 185 | # The detailed output can be found from 186 | # https://github.com/CSkylarL/MSofTimiGP-Response/tree/master/Fig1/result/TimiGP_TNBC_scRNA_marker_for_spatial/Wolf_GSE194040_ISPY2_ptx_pem_TNBC -------------------------------------------------------------------------------- /inst/extdata/CellType_summary.csv: -------------------------------------------------------------------------------- 1 | Dataset,No.Markers,Full.Name,Method.Name,Paper.Name 2 | Charoentong2017,26,Activated B cell,aB,Activated B cell 3 | Charoentong2017,25,Activated CD4 T cell,aCD4 T,Activated CD4 T cell 4 | Charoentong2017,26,Activated CD8 T cell,aCD8 T,Activated CD8 T cell 5 | Charoentong2017,35,Activated dendritic cell,aDC,Activated dendritic cell 6 | Charoentong2017,40,CD56bright natural killer cell,CD56bright NK,CD56bright natural killer cell 7 | Charoentong2017,16,CD56dim natural killer cell,CD56dim NK,CD56dim natural killer cell 8 | Charoentong2017,28,Central memory CD4 T cell,CD4 Tcm,Central memory CD4 T cell 9 | Charoentong2017,21,Central memory CD8 T cell,CD8 Tcm,Central memory CD8 T cell 10 | Charoentong2017,27,Effector memeory CD4 T cell,CD4 Tem,Effector memeory CD4 T cell 11 | Charoentong2017,25,Effector memeory CD8 T cell,CD8 Tem,Effector memeory CD8 T cell 12 | Charoentong2017,17,Eosinophil,Eosinophil,Eosinophil 13 | Charoentong2017,31,Gamma delta T cell,Tgd,Gamma delta T cell 14 | Charoentong2017,19,Immature B cell,iB,Immature B cell 15 | Charoentong2017,23,Immature dendritic cell,iDC,Immature dendritic cell 16 | Charoentong2017,33,Macrophage,Macrophage,Macrophage 17 | Charoentong2017,17,Mast cell,Mast,Mast cell 18 | Charoentong2017,20,Myeloid-derived suppressor cell,MDSC,MDSC 19 | Charoentong2017,14,Memory B cell,Memory B,Memory B cell 20 | Charoentong2017,21,Monocyte,Monocyte,Monocyte 21 | Charoentong2017,35,Natural killer cell,NK,Natural killer cell 22 | Charoentong2017,44,Natural killer T cell,NKT,Natural killer T cell 23 | Charoentong2017,18,Neutrophil,Neutrophil,Neutrophil 24 | Charoentong2017,32,Plasmacytoid dendritic cell,pDC,Plasmacytoid dendritic cell 25 | Charoentong2017,20,Regulatory T cell,Treg,Regulatory T cell 26 | Charoentong2017,36,Follicular helper T cell,Tfh,T follicular helper cell 27 | Charoentong2017,77,Type 1 helper T cell,Th1,Type 1 T helper cell 28 | Charoentong2017,27,Type 17 helper T cell,Th17,Type 17 T helper cell 29 | Charoentong2017,29,Type 2 helper T cell,Th2,Type 2 T helper cell 30 | Bindea2013,5,Activated dendritic cell,aDC,aDC 31 | Bindea2013,34,B cell,B,B cells 32 | Bindea2013,37,CD8 T cell,CD8 T,CD8 T cells 33 | Bindea2013,17,Cytotoxic cell,Cytotoxic,Cytotoxic cells 34 | Bindea2013,7,Dendritic cell,DC,DC 35 | Bindea2013,32,Eosinophil,Eosinophil,Eosinophils 36 | Bindea2013,31,Immature dendritic cell,iDC,iDC 37 | Bindea2013,33,Macrophage,Macrophage,Macrophages 38 | Bindea2013,31,Mast cell,Mast,Mast cells 39 | Bindea2013,31,Neutrophil,Neutrophil,Neutrophils 40 | Bindea2013,11,CD56bright Natural killer cell,CD56bright NK,NK CD56bright cells 41 | Bindea2013,15,CD56dim Natural killer cell,CD56dim NK,NK CD56dim cells 42 | Bindea2013,37,Natural killer cell,NK,NK cells 43 | Bindea2013,18,T cell,T,T cells 44 | Bindea2013,23,Helper T cell,Th,T helper cells 45 | Bindea2013,39,Central memory T cell,Tcm,Tcm 46 | Bindea2013,15,Effector memory T cell,Tem,Tem 47 | Bindea2013,32,Follicular helper T cell,Tfh,TFH 48 | Bindea2013,6,Gamma delta T cell,Tgd,Tgd 49 | Bindea2013,27,Type 1 helper T cell,Th1,Th1 cells 50 | Bindea2013,27,Type 2 helper T cell,Th2,Th2 cells 51 | Bindea2013,37,Tumor Cell,Tumor,SW480 cancer cells 52 | Xu2018,2,B cell,B,B cell 53 | Xu2018,2,Basophil,Basophil,Basophil 54 | Xu2018,3,CD4 T cell,CD4 T,CD4 T cell 55 | Xu2018,8,CD8 T cell,CD8 T,CD8 T cell 56 | Xu2018,5,Dendritic cell,DC,Dendritic cell 57 | Xu2018,3,Eosinophil,Eosinophil,Eosinophil 58 | Xu2018,5,Macrophage,Macrophage,Macrophage 59 | Xu2018,2,Myeloid-derived suppressor cell,MDSC,MDSC 60 | Xu2018,3,Monocyte,Monocyte,Monocyte 61 | Xu2018,6,Neutrophil,Neutrophil,Neutrophil 62 | Xu2018,8,Natural killer cell,NK,NK cell 63 | Xu2018,19,T cell,T,T cell 64 | Xu2018,4,Type 1 helper T cell,Th1,TH1 cell 65 | Xu2018,4,Type 17 helper T cell,Th17,TH17 cell 66 | Xu2018,3,Type 2 helper T cell,Th2,Th2 cell 67 | Xu2018,2,Type 22 helper T cell,Th22,TH22 cell 68 | Xu2018,6,Regulatory T cell,Treg,Treg cell 69 | Tirosh2016,88,Cancer-associated fibroblast,CAF,CAFs 70 | Tirosh2016,47,Melanoma,Melanoma,melanoma 71 | Tirosh2016,31,B cell,B,B cells 72 | Tirosh2016,92,Macrophage,Macrophage,Macrophages 73 | Tirosh2016,38,T cell,T,T cells 74 | Tirosh2016,95,Endothelial cell,Endo,Endothelial cells 75 | Zheng2021,17,CD4.c01(na?ve T cell),CD4+Tn,CD4.c01(Tn) 76 | Zheng2021,24,CD4.c02(CXCR5+ pre-follicular helper T cell ),CD4+CXCR5+ pre-Tfh,CD4.c02(CXCR5+ pre-Tfh) 77 | Zheng2021,21,CD4.c03(ADSL+ na?ve T cell),CD4+ADSL+ Tn,CD4.c03(ADSL+ Tn) 78 | Zheng2021,8,CD4.c04(IL7R- na?ve T cell),CD4+IL7R- Tn,CD4.c04(IL7R- Tn) 79 | Zheng2021,23,CD4.c05(TNF+ T cell),CD4+TNF+ T,CD4.c05(TNF+ T) 80 | Zheng2021,19,CD4.c06(AREG+ memory T cell),CD4+AREG+ Tm,CD4.c06(AREG+ Tm) 81 | Zheng2021,17,CD4.c07(TIMP1+ memory T cell),CD4+TIMP1+ Tm,CD4.c07(TIMP1+ Tm) 82 | Zheng2021,26,CD4.c08(CREM+ memory T cell),CD4+CREM+ Tm,CD4.c08(CREM+ Tm) 83 | Zheng2021,30,CD4.c09(CCL5+ memory T cell),CD4+CCL5+ Tm,CD4.c09(CCL5+ Tm) 84 | Zheng2021,28,CD4.c10(CAPG+ memory T cell),CD4+CAPG+ Tm,CD4.c10(CAPG+ Tm) 85 | Zheng2021,30,CD4.c11(CAPG+CREM- memory T cell),CD4+CAPG+CREM- Tm,CD4.c11(CAPG+CREM- Tm) 86 | Zheng2021,30,CD4.c12(GZMK+ effector memory T cell),CD4+GZMK+ Tem,CD4.c12(GZMK+ Tem) 87 | Zheng2021,30,CD4.c13(terminally differentiated effector memory or effector T cell),CD4+Temra,CD4.c13(Temra) 88 | Zheng2021,26,CD4.c14(CCR6+ Type 17 helper T cell),CD4+CCR6+ Th17,CD4.c14(CCR6+ Th17) 89 | Zheng2021,30,CD4.c15(IL26+ Type 17 helper T cell),CD4+IL26+ Th17,CD4.c15(IL26+ Th17) 90 | Zheng2021,25,CD4.c16(IL21+ follicular helper T cell),CD4+IL21+ Tfh,CD4.c16(IL21+ Tfh) 91 | Zheng2021,30,CD4.c17(IFNG+ follicular helper/ Typer 1 helper dual-functional T cell,CD4+IFNG+ Tfh/Th1,CD4.c17(IFNG+ Tfh/Th1) 92 | Zheng2021,14,CD4.c18(TNFRSF9- regulatory T cell),CD4+TNFRSF9- Treg,CD4.c18(TNFRSF9- Treg) 93 | Zheng2021,23,CD4.c19(S1PR1+ regulatory T cell),CD4+S1PR1+ Treg,CD4.c19(S1PR1+ Treg) 94 | Zheng2021,30,CD4.c20(TNFRSF9+ regulatory T cell),CD4+TNFRSF9+ Treg,CD4.c20(TNFRSF9+ Treg) 95 | Zheng2021,30,CD4.c21(ISG+ regulatory T cell),CD4+ISG+ Treg,CD4.c21(ISG+ Treg) 96 | Zheng2021,17,CD4.c22(ISG+ helper T cell),CD4+ISG+ Th,CD4.c22(ISG+ Th) 97 | Zheng2021,21,CD4.c23(NME1+CCR4- T cell),CD4+NME1+CCR4- T,CD4.c23(NME1+CCR4- T) 98 | Zheng2021,25,CD4.c24(NME1+CCR4+ T cell),CD4+NME1+CCR4+ T,CD4.c24(NME1+CCR4+ T) 99 | Zheng2021,26,CD8.c01(na?ve T cell),CD8+Tn,CD8.c01(Tn) 100 | Zheng2021,14,CD8.c02(IL7R+ memory T cell),CD8+IL7R+ Tm,CD8.c02(IL7R+ Tm) 101 | Zheng2021,16,CD8.c04(ZNF683+CXCR6- memory T cell),CD8+ZNF683+CXCR6- Tm,CD8.c04(ZNF683+CXCR6- Tm) 102 | Zheng2021,17,CD8.c05(GZMK+ early effector memory T cell),CD8+GZMK+ early Tem,CD8.c05(GZMK+ early Tem) 103 | Zheng2021,21,CD8.c06(GZMK+ effector memory T cell),CD8+GZMK+ Tem,CD8.c06(GZMK+ Tem) 104 | Zheng2021,23,CD8.c07(terminally differentiated effector memory or effector T cell),CD8+Temra,CD8.c07(Temra) 105 | Zheng2021,24,CD8.c08(KIR+EOMES+ Natural killer-like T cell),CD8+KIR+EOMES+ NK-like,CD8.c08(KIR+EOMES+ NK-like) 106 | Zheng2021,22,CD8.c09(KIR+TXK+ Natural killer-like T cell),CD8+KIR+TXK+ NK-like,CD8.c09(KIR+TXK+ NK-like) 107 | Zheng2021,24,CD8.c10(ZNF683+CXCR6+ tissue-resident memory T cell),CD8+ZNF683+CXCR6+ Trm,CD8.c10(ZNF683+CXCR6+ Trm) 108 | Zheng2021,28,CD8.c11(GZMK+ exhausted T cell),CD8+GZMK+ Tex,CD8.c11(GZMK+ Tex) 109 | Zheng2021,30,CD8.c12(terminal exhausted T cell),CD8+terminal Tex,CD8.c12(terminal Tex) 110 | Zheng2021,16,CD8.c13(OXPHOS- exhausted T cell),CD8+OXPHOS- Tex,CD8.c13(OXPHOS- Tex) 111 | Zheng2021,23,CD8.c14(TCF7+ exhausted T cell),CD8+TCF7+ Tex,CD8.c14(TCF7+ Tex) 112 | Zheng2021,18,CD8.c15(ISG+ CD8+ T cell),CD8+ISG+ CD8+ T,CD8.c15(ISG+ CD8+ T) 113 | Zheng2021,29,CD8.c16(Type 17 T cell),CD8+Tc17,CD8.c16(Tc17) 114 | Zheng2021,21,CD8.c17(NME1+ T cell),CD8+NME1+ T,CD8.c17(NME1+ T) 115 | Newman2015,62,Memory B cell,Bm,B.cells.memory 116 | Newman2015,60,Na?ve B cell,Bn,B.cells.naive 117 | Newman2015,53,Activated dendritic cell,aDC,Dendritic.cells.activated 118 | Newman2015,40,Resting dendritic cell,rDC,Dendritic.cells.resting 119 | Newman2015,51,Eosinophil,Eosinophil,Eosinophils 120 | Newman2015,33,Macrophage.M0,M0,Macrophages.M0 121 | Newman2015,48,Macrophage.M1,M1,Macrophages.M1 122 | Newman2015,37,Macrophage.M2,M2,Macrophages.M2 123 | Newman2015,38,Activated mast cell,aMast,Mast.cells.activated 124 | Newman2015,38,Resting mast cell,rMast,Mast.cells.resting 125 | Newman2015,52,Monocyte,Monocyte,Monocytes 126 | Newman2015,60,Neutrophil,Neutrophil,Neutrophils 127 | Newman2015,59,Activated NK cell,aNK,NK.cells.activated 128 | Newman2015,57,Resting NK cell,rNK,NK.cells.resting 129 | Newman2015,49,Plasma cell,Plasma,Plasma.cells 130 | Newman2015,40,Activated Memory CD4 T cell,aCD4 Tm,T.cells.CD4.memory.activated 131 | Newman2015,64,Resting Memory CD4 T cell,rCD4 Tm,T.cells.CD4.memory.resting 132 | Newman2015,52,Naive CD4 T cell,CD4 Tn,T.cells.CD4.naive 133 | Newman2015,68,CD8 T cell,CD8 T,T.cells.CD8 134 | Newman2015,57,Follicular helper T cell,Tfh,T.cells.follicular.helper 135 | Newman2015,58,Gamma delta T cell,Tgd,T.cells.gamma.delta 136 | Newman2015,64,Regulatory T cell,Treg,T.cells.regulatory..Tregs. -------------------------------------------------------------------------------- /inst/extdata/Tirosh2016_tableS3_melanoma.txt: -------------------------------------------------------------------------------- 1 | CellType Gene 2 | melanoma MIA 3 | melanoma TYR 4 | melanoma SLC45A2 5 | melanoma CDH19 6 | melanoma PMEL 7 | melanoma SLC24A5 8 | melanoma MAGEA6 9 | melanoma GJB1 10 | melanoma PLP1 11 | melanoma PRAME 12 | melanoma CAPN3 13 | melanoma ERBB3 14 | melanoma GPM6B 15 | melanoma S100B 16 | melanoma FXYD3 17 | melanoma PAX3 18 | melanoma S100A1 19 | melanoma MLANA 20 | melanoma SLC26A2 21 | melanoma GPR143 22 | melanoma CSPG4 23 | melanoma SOX10 24 | melanoma MLPH 25 | melanoma LOXL4 26 | melanoma PLEKHB1 27 | melanoma RAB38 28 | melanoma QPCT 29 | melanoma BIRC7 30 | melanoma MFI2 31 | melanoma LINC00473 32 | melanoma SEMA3B 33 | melanoma SERPINA3 34 | melanoma PIR 35 | melanoma MITF 36 | melanoma ST6GALNAC2 37 | melanoma ROPN1B 38 | melanoma CDH1 39 | melanoma ABCB5 40 | melanoma QDPR 41 | melanoma SERPINE2 42 | melanoma ATP1A1 43 | melanoma ST3GAL4 44 | melanoma CDK2 45 | melanoma ACSL3 46 | melanoma NT5DC3 47 | melanoma IGSF8 48 | melanoma MBP 49 | CAFs FAP 50 | CAFs THY1 51 | CAFs DCN 52 | CAFs COL1A1 53 | CAFs COL1A2 54 | CAFs COL6A1 55 | CAFs COL6A2 56 | CAFs COL6A3 57 | CAFs CXCL14 58 | CAFs LUM 59 | CAFs COL3A1 60 | CAFs DPT 61 | CAFs ISLR 62 | CAFs PODN 63 | CAFs CD248 64 | CAFs FGF7 65 | CAFs MXRA8 66 | CAFs PDGFRL 67 | CAFs COL14A1 68 | CAFs MFAP5 69 | CAFs MEG3 70 | CAFs SULF1 71 | CAFs AOX1 72 | CAFs SVEP1 73 | CAFs LPAR1 74 | CAFs PDGFRB 75 | CAFs TAGLN 76 | CAFs IGFBP6 77 | CAFs FBLN1 78 | CAFs CA12 79 | CAFs SPOCK1 80 | CAFs TPM2 81 | CAFs THBS2 82 | CAFs FBLN5 83 | CAFs TMEM119 84 | CAFs ADAM33 85 | CAFs PRRX1 86 | CAFs PCOLCE 87 | CAFs IGF2 88 | CAFs GFPT2 89 | CAFs PDGFRA 90 | CAFs CRISPLD2 91 | CAFs CPE 92 | CAFs F3 93 | CAFs MFAP4 94 | CAFs C1S 95 | CAFs PTGIS 96 | CAFs LOX 97 | CAFs CYP1B1 98 | CAFs CLDN11 99 | CAFs SERPINF1 100 | CAFs OLFML3 101 | CAFs COL5A2 102 | CAFs ACTA2 103 | CAFs MSC 104 | CAFs VASN 105 | CAFs ABI3BP 106 | CAFs C1R 107 | CAFs ANTXR1 108 | CAFs MGST1 109 | CAFs C3 110 | CAFs PALLD 111 | CAFs FBN1 112 | CAFs CPXM1 113 | CAFs CYBRD1 114 | CAFs IGFBP5 115 | CAFs PRELP 116 | CAFs PAPSS2 117 | CAFs MMP2 118 | CAFs CKAP4 119 | CAFs CCDC80 120 | CAFs ADAMTS2 121 | CAFs TPM1 122 | CAFs PCSK5 123 | CAFs ELN 124 | CAFs CXCL12 125 | CAFs OLFML2B 126 | CAFs PLAC9 127 | CAFs RCN3 128 | CAFs LTBP2 129 | CAFs NID2 130 | CAFs SCARA3 131 | CAFs AMOTL2 132 | CAFs TPST1 133 | CAFs MIR100HG 134 | CAFs CTGF 135 | CAFs RARRES2 136 | CAFs FHL2 137 | Endothelial cells PECAM1 138 | Endothelial cells VWF 139 | Endothelial cells CDH5 140 | Endothelial cells CLDN5 141 | Endothelial cells PLVAP 142 | Endothelial cells ECSCR 143 | Endothelial cells SLCO2A1 144 | Endothelial cells CCL14 145 | Endothelial cells MMRN1 146 | Endothelial cells MYCT1 147 | Endothelial cells KDR 148 | Endothelial cells TM4SF18 149 | Endothelial cells TIE1 150 | Endothelial cells ERG 151 | Endothelial cells FABP4 152 | Endothelial cells SDPR 153 | Endothelial cells HYAL2 154 | Endothelial cells FLT4 155 | Endothelial cells EGFL7 156 | Endothelial cells ESAM 157 | Endothelial cells CXorf36 158 | Endothelial cells TEK 159 | Endothelial cells TSPAN18 160 | Endothelial cells EMCN 161 | Endothelial cells MMRN2 162 | Endothelial cells ELTD1 163 | Endothelial cells PDE2A 164 | Endothelial cells NOS3 165 | Endothelial cells ROBO4 166 | Endothelial cells APOLD1 167 | Endothelial cells PTPRB 168 | Endothelial cells RHOJ 169 | Endothelial cells RAMP2 170 | Endothelial cells GPR116 171 | Endothelial cells F2RL3 172 | Endothelial cells JUP 173 | Endothelial cells CCBP2 174 | Endothelial cells GPR146 175 | Endothelial cells RGS16 176 | Endothelial cells TSPAN7 177 | Endothelial cells RAMP3 178 | Endothelial cells PLA2G4C 179 | Endothelial cells TGM2 180 | Endothelial cells LDB2 181 | Endothelial cells PRCP 182 | Endothelial cells ID1 183 | Endothelial cells SMAD1 184 | Endothelial cells AFAP1L1 185 | Endothelial cells ELK3 186 | Endothelial cells ANGPT2 187 | Endothelial cells LYVE1 188 | Endothelial cells ARHGAP29 189 | Endothelial cells IL3RA 190 | Endothelial cells ADCY4 191 | Endothelial cells TFPI 192 | Endothelial cells TNFAIP1 193 | Endothelial cells SYT15 194 | Endothelial cells DYSF 195 | Endothelial cells PODXL 196 | Endothelial cells SEMA3A 197 | Endothelial cells DOCK9 198 | Endothelial cells F8 199 | Endothelial cells NPDC1 200 | Endothelial cells TSPAN15 201 | Endothelial cells CD34 202 | Endothelial cells THBD 203 | Endothelial cells ITGB4 204 | Endothelial cells RASA4 205 | Endothelial cells COL4A1 206 | Endothelial cells ECE1 207 | Endothelial cells GFOD2 208 | Endothelial cells EFNA1 209 | Endothelial cells PVRL2 210 | Endothelial cells GNG11 211 | Endothelial cells HERC2P2 212 | Endothelial cells MALL 213 | Endothelial cells HERC2P9 214 | Endothelial cells PPM1F 215 | Endothelial cells PKP4 216 | Endothelial cells LIMS3 217 | Endothelial cells CD9 218 | Endothelial cells RAI14 219 | Endothelial cells ZNF521 220 | Endothelial cells RGL2 221 | Endothelial cells HSPG2 222 | Endothelial cells TGFBR2 223 | Endothelial cells RBP1 224 | Endothelial cells FXYD6 225 | Endothelial cells MATN2 226 | Endothelial cells S1PR1 227 | Endothelial cells PIEZO1 228 | Endothelial cells PDGFA 229 | Endothelial cells ADAM15 230 | Endothelial cells HAPLN3 231 | Endothelial cells APP 232 | Macrophages CD163 233 | Macrophages CD14 234 | Macrophages CSF1R 235 | Macrophages C1QC 236 | Macrophages VSIG4 237 | Macrophages C1QA 238 | Macrophages FCER1G 239 | Macrophages F13A1 240 | Macrophages TYROBP 241 | Macrophages MSR1 242 | Macrophages C1QB 243 | Macrophages MS4A4A 244 | Macrophages FPR1 245 | Macrophages S100A9 246 | Macrophages IGSF6 247 | Macrophages LILRB4 248 | Macrophages FPR3 249 | Macrophages SIGLEC1 250 | Macrophages LILRA1 251 | Macrophages LYZ 252 | Macrophages HK3 253 | Macrophages SLC11A1 254 | Macrophages CSF3R 255 | Macrophages CD300E 256 | Macrophages PILRA 257 | Macrophages FCGR3A 258 | Macrophages AIF1 259 | Macrophages SIGLEC9 260 | Macrophages FCGR1C 261 | Macrophages OLR1 262 | Macrophages TLR2 263 | Macrophages LILRB2 264 | Macrophages C5AR1 265 | Macrophages FCGR1A 266 | Macrophages MS4A6A 267 | Macrophages C3AR1 268 | Macrophages HCK 269 | Macrophages IL4I1 270 | Macrophages LST1 271 | Macrophages LILRA5 272 | Macrophages CSTA 273 | Macrophages IFI30 274 | Macrophages CD68 275 | Macrophages TBXAS1 276 | Macrophages FCGR1B 277 | Macrophages LILRA6 278 | Macrophages CXCL16 279 | Macrophages NCF2 280 | Macrophages RAB20 281 | Macrophages MS4A7 282 | Macrophages NLRP3 283 | Macrophages LRRC25 284 | Macrophages ADAP2 285 | Macrophages SPP1 286 | Macrophages CCR1 287 | Macrophages TNFSF13 288 | Macrophages RASSF4 289 | Macrophages SERPINA1 290 | Macrophages MAFB 291 | Macrophages IL18 292 | Macrophages FGL2 293 | Macrophages SIRPB1 294 | Macrophages CLEC4A 295 | Macrophages MNDA 296 | Macrophages FCGR2A 297 | Macrophages CLEC7A 298 | Macrophages SLAMF8 299 | Macrophages SLC7A7 300 | Macrophages ITGAX 301 | Macrophages BCL2A1 302 | Macrophages PLAUR 303 | Macrophages SLCO2B1 304 | Macrophages PLBD1 305 | Macrophages APOC1 306 | Macrophages RNF144B 307 | Macrophages SLC31A2 308 | Macrophages PTAFR 309 | Macrophages NINJ1 310 | Macrophages ITGAM 311 | Macrophages CPVL 312 | Macrophages PLIN2 313 | Macrophages C1orf162 314 | Macrophages FTL 315 | Macrophages LIPA 316 | Macrophages CD86 317 | Macrophages GLUL 318 | Macrophages FGR 319 | Macrophages GK 320 | Macrophages TYMP 321 | Macrophages GPX1 322 | Macrophages NPL 323 | Macrophages ACSL1 324 | B cells CD19 325 | B cells CD79A 326 | B cells CD79B 327 | B cells BLK 328 | B cells MS4A1 329 | B cells BANK1 330 | B cells IGLL3P 331 | B cells FCRL1 332 | B cells PAX5 333 | B cells CLEC17A 334 | B cells CD22 335 | B cells BCL11A 336 | B cells VPREB3 337 | B cells HLA-DOB 338 | B cells STAP1 339 | B cells FAM129C 340 | B cells TLR10 341 | B cells RALGPS2 342 | B cells AFF3 343 | B cells POU2AF1 344 | B cells CXCR5 345 | B cells PLCG2 346 | B cells HVCN1 347 | B cells CCR6 348 | B cells P2RX5 349 | B cells BLNK 350 | B cells KIAA0226L 351 | B cells POU2F2 352 | B cells IRF8 353 | B cells FCRLA 354 | B cells CD37 355 | T cells CD2 356 | T cells CD3D 357 | T cells CD3E 358 | T cells CD3G 359 | T cells CD8A 360 | T cells SIRPG 361 | T cells TIGIT 362 | T cells GZMK 363 | T cells ITK 364 | T cells SH2D1A 365 | T cells CD247 366 | T cells PRF1 367 | T cells NKG7 368 | T cells IL2RB 369 | T cells SH2D2A 370 | T cells KLRK1 371 | T cells ZAP70 372 | T cells CD7 373 | T cells CST7 374 | T cells LAT 375 | T cells PYHIN1 376 | T cells SLA2 377 | T cells STAT4 378 | T cells CD6 379 | T cells CCL5 380 | T cells CD96 381 | T cells TC2N 382 | T cells FYN 383 | T cells LCK 384 | T cells TCF7 385 | T cells TOX 386 | T cells IL32 387 | T cells SPOCK2 388 | T cells SKAP1 389 | T cells CD28 390 | T cells CBLB 391 | T cells APOBEC3G 392 | T cells PRDM1 393 | -------------------------------------------------------------------------------- /inst/extdata/Xu2018_Signature.txt: -------------------------------------------------------------------------------- 1 | GeneSymbol Steps Direction ImmuneCellType 2 | IL10 1 positive Multiple 3 | TGFB1 1 positive Multiple 4 | HMGB1 1 positive Multiple 5 | ANXA1 1 positive Multiple 6 | CALR 1 positive Multiple 7 | CXCL10 1 positive Multiple 8 | PDIA3 1 positive Multiple 9 | HSPA1A 1 positive Multiple 10 | HSPA1B 1 positive Multiple 11 | HSPA2 1 positive Multiple 12 | HSPA8 1 positive Multiple 13 | HSPA4 1 positive Multiple 14 | HSPA14 1 positive Multiple 15 | HSPA5 1 positive Multiple 16 | HSPA6 1 positive Multiple 17 | HSPA9 1 positive Multiple 18 | HSPA13 1 positive Multiple 19 | HSPA7 1 positive Multiple 20 | HSPA8 1 positive Multiple 21 | HSPA12A 1 positive Multiple 22 | HSPA12B 1 positive Multiple 23 | HSP90AA1 1 positive Multiple 24 | HSP90AB1 1 positive Multiple 25 | HSP90B1 1 positive Multiple 26 | IFNA2 1 positive Multiple 27 | IFNA1 1 positive Multiple 28 | IFNA13 1 positive Multiple 29 | IFNA6 1 positive Multiple 30 | IFNA21 1 positive Multiple 31 | IFNA4 1 positive Multiple 32 | IFNA8 1 positive Multiple 33 | IFNA5 1 positive Multiple 34 | IFNA7 1 positive Multiple 35 | IFNA14 1 positive Multiple 36 | IFNA16 1 positive Multiple 37 | IFNA10 1 positive Multiple 38 | IFNA17 1 positive Multiple 39 | IFNB1 1 positive Multiple 40 | IFNE 1 positive Multiple 41 | IFNW1 1 positive Multiple 42 | TNF 2 positive Multiple 43 | IL1A 2 positive Multiple 44 | IL1B 2 positive Multiple 45 | IFNA2 2 positive Multiple 46 | IFNA1 2 positive Multiple 47 | IFNA13 2 positive Multiple 48 | IFNA6 2 positive Multiple 49 | IFNA21 2 positive Multiple 50 | IFNA4 2 positive Multiple 51 | IFNA8 2 positive Multiple 52 | IFNA5 2 positive Multiple 53 | IFNA7 2 positive Multiple 54 | IFNA14 2 positive Multiple 55 | IFNA16 2 positive Multiple 56 | IFNA10 2 positive Multiple 57 | IFNA17 2 positive Multiple 58 | CD40LG 2 positive Multiple 59 | CD40 2 positive Multiple 60 | NT5C 2 positive Multiple 61 | HMGB1 2 positive Multiple 62 | TLR1 2 positive Multiple 63 | TLR2 2 positive Multiple 64 | TLR3 2 positive Multiple 65 | TLR4 2 positive Multiple 66 | TLR5 2 positive Multiple 67 | TLR6 2 positive Multiple 68 | TLR7 2 positive Multiple 69 | TLR8 2 positive Multiple 70 | TLR9 2 positive Multiple 71 | TLR10 2 positive Multiple 72 | HLAA 2 positive Multiple 73 | B2M 2 positive Multiple 74 | TAP1 2 positive Multiple 75 | IL10 2 negative Multiple 76 | IL4 2 negative Multiple 77 | IL13 2 negative Multiple 78 | CD3D 3 positive Multiple 79 | CD3E 3 positive Multiple 80 | CD3G 3 positive Multiple 81 | CD247 3 positive Multiple 82 | CD28 3 positive Multiple 83 | TNFRSF9 3 positive Multiple 84 | TNFSF9 3 positive Multiple 85 | TNFRSF4 3 positive Multiple 86 | TNFSF4 3 positive Multiple 87 | CD27 3 positive Multiple 88 | CD70 3 positive Multiple 89 | TNFRSF14 3 positive Multiple 90 | TNFSF14 3 positive Multiple 91 | CD40 3 positive Multiple 92 | CD40LG 3 positive Multiple 93 | TNFRSF18 3 positive Multiple 94 | TNFSF18 3 positive Multiple 95 | TNFRSF25 3 positive Multiple 96 | TNFSF15 3 positive Multiple 97 | TNFRSF8 3 positive Multiple 98 | TNFSF8 3 positive Multiple 99 | HAVCR1 3 positive Multiple 100 | TIMD4 3 positive Multiple 101 | SLAMF7 3 positive Multiple 102 | SLAMF6 3 positive Multiple 103 | SLAMF1 3 positive Multiple 104 | SLAMF9 3 positive Multiple 105 | SLAMF8 3 positive Multiple 106 | CD2 3 positive Multiple 107 | CD48 3 positive Multiple 108 | CD58 3 positive Multiple 109 | CD226 3 positive Multiple 110 | ICOS 3 positive Multiple 111 | ICOSLG 3 positive Multiple 112 | KLRK1 3 positive Multiple 113 | MICA 3 positive Multiple 114 | MICB 3 positive Multiple 115 | RAET1E 3 positive Multiple 116 | RAET1G 3 positive Multiple 117 | CRTAM 3 positive Multiple 118 | CADM1 3 positive Multiple 119 | CTLA4 3 negative Multiple 120 | PDCD1 3 negative Multiple 121 | PDCD1LG2 3 negative Multiple 122 | CD274 3 negative Multiple 123 | CD160 3 negative Multiple 124 | TNFRSF14 3 negative Multiple 125 | BTLA 3 negative Multiple 126 | VSIR 3 negative Multiple 127 | LAIR1 3 negative Multiple 128 | HAVCR1 3 negative Multiple 129 | HAVCR2 3 negative Multiple 130 | LGALS9 3 negative Multiple 131 | TIMD4 3 negative Multiple 132 | CD244 3 negative Multiple 133 | CD48 3 negative Multiple 134 | TIGIT 3 negative Multiple 135 | NECTIN3 3 negative Multiple 136 | LAG3 3 negative Multiple 137 | IL2 3 positive Multiple 138 | IL12A 3 positive Multiple 139 | IL12B 3 positive Multiple 140 | CXCR5 4 positive B cell 141 | CXCL13 4 positive B cell 142 | CCL24 4 positive Basophil 143 | CCL26 4 positive Basophil 144 | CCL19 4 positive CD4 T cell 145 | CX3CL1 4 positive CD4 T cell 146 | CXCL16 4 positive CD4 T cell 147 | CCR5 4 positive CD8 T cell 148 | CXCR3 4 positive CD8 T cell 149 | CXCL10 4 positive CD8 T cell 150 | CXCL9 4 positive CD8 T cell 151 | CCL20 4 positive CD8 T cell 152 | CXCL11 4 positive CD8 T cell 153 | CX3CL1 4 positive CD8 T cell 154 | CXCL16 4 positive CD8 T cell 155 | CCR7 4 positive Dendritic cell 156 | CCL3 4 positive Dendritic cell 157 | CCL4 4 positive Dendritic cell 158 | CCL5 4 positive Dendritic cell 159 | CCL21 4 positive Dendritic cell 160 | CCL11 4 positive Eosinophil 161 | CCL24 4 positive Eosinophil 162 | CCL26 4 positive Eosinophil 163 | CSF1 4 positive Macrophage 164 | CCL2 4 positive Macrophage 165 | CCL3 4 positive Macrophage 166 | CCL4 4 positive Macrophage 167 | CCL5 4 positive Macrophage 168 | CXCR2 4 positive MDSC 169 | CXCL5 4 positive MDSC 170 | CCL2 4 positive Monocyte 171 | CCL7 4 positive Monocyte 172 | CX3CL1 4 positive Monocyte 173 | CXCL1 4 positive Neutrophil 174 | CXCL2 4 positive Neutrophil 175 | CXCL3 4 positive Neutrophil 176 | CXCL8 4 positive Neutrophil 177 | CXCL6 4 positive Neutrophil 178 | CXCL5 4 positive Neutrophil 179 | CXCR3 4 positive NK cell 180 | CXCL10 4 positive NK cell 181 | CXCL9 4 positive NK cell 182 | CCL3 4 positive NK cell 183 | CCL4 4 positive NK cell 184 | CCL5 4 positive NK cell 185 | CXCL11 4 positive NK cell 186 | CX3CL1 4 positive NK cell 187 | CXCR5 4 positive T cell 188 | CCR7 4 positive T cell 189 | CXCL9 4 positive T cell 190 | CCL3 4 positive T cell 191 | CCL4 4 positive T cell 192 | CCL5 4 positive T cell 193 | CCL19 4 positive T cell 194 | CCL21 4 positive T cell 195 | CX3CL1 4 positive T cell 196 | CXCL13 4 positive T cell 197 | CXCR3 4 positive TH1 cell 198 | CXCL10 4 positive TH1 cell 199 | CXCL9 4 positive TH1 cell 200 | CXCL11 4 positive TH1 cell 201 | CCR6 4 positive TH17 cell 202 | CCL20 4 positive TH17 cell 203 | CXCL12 4 positive TH17 cell 204 | CXCR4 4 positive TH17 cell 205 | CCL1 4 positive Th2 cell 206 | CCL17 4 positive Th2 cell 207 | CCL22 4 positive Th2 cell 208 | CCR6 4 positive TH22 cell 209 | CCL20 4 positive TH22 cell 210 | CCR4 4 positive Treg cell 211 | CCR10 4 positive Treg cell 212 | CCL1 4 positive Treg cell 213 | CCL17 4 positive Treg cell 214 | CCL22 4 positive Treg cell 215 | CCL28 4 positive Treg cell 216 | STAT1 5 positive T cell 217 | IRF5 5 positive T cell 218 | KLF2 5 positive T cell 219 | ITGB2 5 positive T cell 220 | ICAM1 5 negative T cell 221 | EZH2 5 negative T cell 222 | DNMT1 5 negative T cell 223 | VEGFA 5 negative T cell 224 | EDNRB 5 negative T cell 225 | CD28 6 positive Multiple 226 | ICOS 6 positive Multiple 227 | ICOSLG 6 positive Multiple 228 | TNFRSF9 6 positive Multiple 229 | TNFSF9 6 positive Multiple 230 | CD27 6 positive Multiple 231 | CD70 6 positive Multiple 232 | TNFRSF4 6 positive Multiple 233 | TNFSF4 6 positive Multiple 234 | TNFSF14 6 positive Multiple 235 | CD40 6 positive Multiple 236 | CD40LG 6 positive Multiple 237 | HLAA 6 positive Multiple 238 | B2M 6 positive Multiple 239 | TAP1 6 positive Multiple 240 | BIRC5 6 positive Multiple 241 | MDM2 6 positive Multiple 242 | MAGEA4 6 positive Multiple 243 | TP53 6 positive Multiple 244 | PDCD1 6 negative Multiple 245 | PDCD1LG2 6 negative Multiple 246 | CD274 6 negative Multiple 247 | CTLA4 6 negative Multiple 248 | BTLA 6 negative Multiple 249 | VTCN1 6 negative Multiple 250 | IFNG 7 positive Multiple 251 | GZMB 7 positive Multiple 252 | PRF1 7 positive Multiple 253 | PDCD1 7 negative Multiple 254 | SMC3 7 negative Multiple 255 | VTCN1 7 negative Multiple 256 | HAVCR2 7 negative Multiple 257 | MICA 7 negative Multiple 258 | MICB 7 negative Multiple 259 | BTLA 7 negative Multiple 260 | VSIR 7 negative Multiple 261 | LAG3 7 negative Multiple 262 | IDO1 7 negative Multiple 263 | IDO2 7 negative Multiple 264 | ARG1 7 negative Multiple 265 | ARG2 7 negative Multiple 266 | NOS1 7 negative Multiple 267 | NOS2 7 negative Multiple 268 | NOS3 7 negative Multiple 269 | TGFB1 7 negative Multiple 270 | IL10 7 negative Multiple 271 | CCL28 7 negative Multiple 272 | CXCL12 7 negative Multiple 273 | CCL2 7 negative Multiple 274 | CXCL8 7 negative Multiple 275 | 276 | -------------------------------------------------------------------------------- /inst/extdata/Zheng2021_tableS2_Tcell.txt: -------------------------------------------------------------------------------- 1 | meta cluster Functional properties TF "cytokine, chemokine and effector molecule" cytokine receptor and chemokines receptor other genes P N T 2 | CD8.c01 Tn "LEF1, TCF7, KLF2, TXK, BACH2" "LTB, FLT3LG, TNFSF8, CMTM8, IL23A, TIMP1, WNT7A" "CCR7, IL7R, IL6R, IFNGR2" "SELL, MAL, EEF1A1, ACTN1, TRABD2A, TPT1, EEF1B2, NELL2, NOSIP, PABPC1" 5.06 0.77 0.63 3 | CD8.c02 IL7R+ Tm "ZFP36L2, TSC22D3" "IL7R, CXCR4" "ZFP36, BTG1, ANXA1, LMNA, CD55, TNFAIP3, FTH1, RGCC, GPR183, PABPC1" 0.21 2.38 0.55 4 | CD8.c04 ZNF683+CXCR6- Tm ZNF683 "CCL5, IL32, GZMA, TNF, CKLF" "ACTB, CD52, TRAF3IP3, SH3BGRL3, SIT1, S100A4, CISH, MYL12A, PTPRCAP, PFN1" 1.2 1.49 0.66 5 | CD8.c05 GZMK+ early Tem EOMES GZMK "CXCR4, CD74, CXCR5, CCR4, CD44" "DUSP2, CMC1, CST7, DKK3, SH2D1A, ENC1, TRAT1, DTHD1, PIK3R1, CRTAM" 0.35 0.98 1.24 6 | CD8.c06 GZMK+ Tem "EOMES, SUB1" "GZMK, GZMA, CCL5, GZMH, IL32, CCL4" "CD74, CCR5, CXCR3" "HLA-DRB1, HLA-DPA1, COTL1, HLA-DPB1, HLA-DQA1, HLA-DQB1, HLA-DRB5, ITM2C, CST7, APOBEC3G" 0.59 0.64 1.67 7 | CD8.c07 Temra "ASCL2, KLF2, KLF3, ZEB2, TBX21" "GZMH, GZMB, GZMM, GZMA" "CX3CR1, CXCR2, CMKLR1, CXCR1" "FGFBP2, FCGR3A, S1PR5, PRSS23, GNLY, NKG7, KLRD1, FGR, PLEK, C1orf21" 7.05 1.34 0.35 8 | CD8.c08 KIR+EOMES+ NK-like "IKZF2, EOMES, NR4A2, LITAF, ZNF331" "GZMK, XCL2, XCL1, GZMM, TNFSF9" "IFNGR1, CXCR4, CD74, IL2RB" "KIR(KIR2DL3,KIR3DL2), CD160, TYROBP, KLRF1, KLRD1, KLRG1, CMC1, GCSAM, DUSP2" 1.27 2.23 0.44 9 | CD8.c09 KIR+TXK+ NK-like "IKZF2, HOPX, TXK, FOSL2, REL" "XCL1, XCL2, AREG, FAM3C, IL32" "IL2RB, IL12RB2" "KIR(KIR2DL3, KIR3DL2, KIR2DL4, KIR2DL1, KIR3DL1), TYROBP, KLRC2, KLRC3, LAT2, B3GNT7" 0.08 2 0.66 10 | CD8.c10 ZNF683+CXCR6+ Trm "ZNF683, HOPX, ID2, ZFP36L2, RBPJ" "CKLF, IL32, GZMB, XCL1, CCL5, GZMA, XCL2" "CXCR6, CXCR3" "CAPG, TMSB4X, S100A4, LGALS3, ACTB, SH3BGRL3, CD52, LGALS1, ITGA1, LDLRAD4" 0.17 1.11 1.18 11 | CD8.c11 GZMK+ Tex "TOX, TSC22D1, PRDM1, TRPS1, EOMES" "GZMK, CXCL13, GZMA, CCL3, CCL5, CCL3L3, TNFSF4, CCL4, IFNG, NAMPT" "CD74, CXCR6, CCR5" "HAVCR2, CD27, VCAM1, LYST, PDCD1, DUSP4, CTLA4, TNFRSF9, HLA-DQA1, HLA-DRB1" 0.09 0.38 3.38 12 | CD8.c12 terminal Tex "RBPJ, ETV1, TOX, ZBED2, TOX2" "CXCL13, TNFSF4, FAM3C, GZMB, CSF1, CCL3, CD70, IFNG, NAMPT, FASLG" "IL2RA, CXCR6, CD74, IL2RB, IL2RG" "TNFRSF9, LAYN, ENTPD1, HAVCR2, CTLA4, KRT86, TNFRSF18, GEM, TIGIT, DUSP4" 0.02 0.23 5.82 13 | CD8.c13 OXPHOS- Tex "ETV1, PRDM1" "CXCL13, CSF1, CCL3, FAM3C" "LAYN, HAVCR2, CTLA4, ENTPD1, TNFRSF9, TNFRSF18, PHLDA1, ACP5, TIGIT, KIR2DL4" 0.06 0.34 3.76 14 | CD8.c14 TCF7+ Tex "TSHZ2, TCF7, NR3C1, TOX, BATF" "CXCL13, EBI3, TNFSF8, CD40LG" "CCR7, IL6R, IFNAR2, CCR4" "LHFP, CD200, GNG4, TNFRSF4, IGFL2, CPM, NMB, SESN3, BTLA, IGFBP4" 0.34 0.7 1.68 15 | CD8.c15 ISG+ CD8+ T "PLSCR1, STAT1, IRF7, STAT2, SP100" TNFSF10 "CCR1, CD74" "IFIT1, RSAD2, IFIT3, IFI44L, MX1, IFI6, OAS1, CMPK2, ISG15, OAS3" 0.06 0.09 12.87 16 | CD8.c16 Tc17 "RORC, ZBTB16, CEBPD, RORA, NR1D1" "CCL20, CD40LG, LTB, TNFSF13B, IL26, IL17A, FLT3LG, TNF, IL23A" "CCR6, IL23R, IL7R, IL17RE, IL18RAP" "SLC4A10, KLRB1, TMIGD2, IL4I1, NCR3, LTK, CA2, ME1, AQP3, ADAM12" 1.31 1.8 0.54 17 | CD8.c17 NME1+ T "ENO1, HMGA1, GTF3A, MYB, MXD3" "HMGB1, MIF, GPI, CKLF" "CD74, CXCR3" "ACTB, MND1, SPC24, PFN1, ACTG1, CENPA, KIFC1, SKA3, GAPDH, KIF20A" 2.49 0.29 1.6 18 | CD4.c01 Tn "TCF7, LEF1, TXK, KLF2, SCML1" "CCR7, IL7R" "EEF1A1, SELL, EEF1B2, PLAC8, TPT1, ACTN1, GIMAP7, MAL, LINC00861, FHIT" 3.68 1.31 0.43 19 | CD4.c02 CXCR5+ pre-Tfh "TCF7, NR3C1, NR4A2, TSHZ2, LEF1" "CMTM8, TNFSF8, AREG, CD40LG" "CCR7, CXCR5, IL6ST, CXCR4, CCR4" "PASK, FAAH2, SESN3, SLC2A3, FAM177A1, MBP, SH3TC1, RNASET2, PABPC1, IFITM1" 1.02 1.3 0.81 20 | CD4.c03 ADSL+ Tn "TCF7, LEF1, TXK, KLF2, MYC" "LTB, IL16, CMTM8" "CCR7, IL6R, IL6ST" "C1orf228, PASK, SELL, LDHB, GIMAP4, LIMS2, ANKRD55, NOSIP, COTL1, DGKA" 5.59 0.73 0.39 21 | CD4.c04 IL7R- Tn CCR7 "EEF1B2, EEF1A1, ACTG1, LDHB, NACA, FAU, BTF3" 3.52 0.83 0.54 22 | CD4.c05 TNF+ T "HOPX, ID2, EGR1" "CD40LG, CCL5, GZMA, TNF, CKLF, IFNG, CCL4, FASLG" "CCR2, CXCR3" "CD52, SH3BGRL3, ACTB, MYL12A, SIT1, CISH, CAPG, CD69, CD99, LCP2" 0.86 2.26 0.52 23 | CD4.c06 AREG+ Tm "ZFP36L2, KLF2, KLF3, TCF7" "CD40LG, AREG" "IL7R, CCR7, CXCR4" "ANXA1, EEF1A1, TPT1, GPR183, CD55, PABPC1, EEF1B2, S1PR1, PTGER2, PLAC8" 0.99 2 0.57 24 | CD4.c07 TIMP1+ Tm "KLF2, HOPX, LMO4" "TIMP1, FLT3LG, CD40LG" IL7R "S100A11, S100A10, ANXA1, S100A4, SH3BGRL3, CD52, S100A6, VIM, CAPG, EMP3" 3.42 0.67 0.62 25 | CD4.c08 CREM+ Tm "CREM, ZFP36L2, ZNF331, NR4A2, SKIL" "CCL5, GZMA, TGFB1, AREG, CXCL16, GZMK" "CXCR4, IFNGR1, GPR35, CD44, IL7R" "ZFP36, FTH1, SRGN, FAM177A1, TNFAIP3, YPEL5, LMNA, ANXA1, PTGER4, CDKN1A" 0.01 2.76 0.61 26 | CD4.c09 CCL5+ Tm "ZFP36L2, HOPX, ID2, BHLHE40, NR4A2" "CCL5, GZMA, GZMK, XCL1, CD40LG, CCL4, XCL2, GZMH, IFNG, GZMM" "CXCR4, IL7R, IFNGR1, CD44, IL18RAP" "ANXA1, ALOX5AP, GLUL, ITGA1, PARP8, PTGER4, CD69, ZFP36, CD99, CLU" 0.25 2.14 0.7 27 | CD4.c10 CAPG+ Tm "HOPX, BHLHE40, ID2, RBPJ, PPARG" "GZMA, CCL5, CKLF, TIMP1, IL32, TGFB1, CD40LG, HMGB1, CSF2" "CXCR3, CD74, IL2RG, CXCR6" "SH3BGRL3, TMSB4X, ACTB, CAPG, ALOX5AP, CD52, PFN1, S100A11, S100A4, COTL1" 1.12 0.75 1.17 28 | CD4.c11 CAPG+CREM- Tm "HOPX, ID2, BHLHE40, ZFP36L2, ZNF683" "CCL5, GZMA, GZMH, CCL4, GZMB, CKLF, IFNG, XCL1, GZMK, CD40LG" "CXCR3, IFNGR1, CXCR6, IL18RAP, GPR35" "SH3BGRL3, ALOX5AP, CAPG, CD52, ANXA1, CD99, TMSB4X, HCST, S100A4, CLU" 0.8 1.35 0.85 29 | CD4.c12 GZMK+ Tem "EOMES, LITAF, NFATC2, RUNX3, NR4A2" "GZMK, CCL4, GZMA, CCL5, GZMH, TNFSF9, CCL3L3, IFNG, FASLG, CCL3" "CD74, CCR5, CXCR4, CXCR3, CD4" "NKG7, CST7, CRTAM, CCL4L2, ENC1, ITM2C, SLAMF7, AOAH, F2R, DTHD1" 0.38 1.2 1.14 30 | CD4.c13 Temra "HOPX, ZEB2, ZNF683, EOMES, TBX21" "GZMH, GZMB, CCL5, CCL4, GZMA, XCL2, GZMM, CCL3, FASLG, GZMK" "CX3CR1, CMKLR1, IL5RA, CXCR2, IL18RAP" "FGFBP2, NKG7, GNLY, S1PR5, KLRD1, C1orf21, PRF1, PLEK, CTSW, PRSS23" 2.87 1.91 0.34 31 | CD4.c14 CCR6+ Th17 "BHLHE40, HOPX, ZFP36L2, MYBL1, RORA" "TNFSF13B, CCL20, CD40LG, CCL5, TIMP1, FLT3LG" "IL7R, CXCR4, CCR6, IFNGR1, GPR35" "ANXA1, KLRB1, IL4I1, VIM, FKBP11, CAPG, ABCB1, TPT1, PERP, DPP4" 0.66 1.52 0.81 32 | CD4.c15 IL26+ Th17 "RORC, RORA, CEBPD, RUNX2, ID2" "IL26, IL17F, IL17A, TNFSF13B, CCL20, CD40LG, GZMA, CKLF, IL22, TNFSF14" "CXCR6, CCR6, IL23R, IL17RE, IL7R" "KLRB1, CTSH, CA10, CAPG, PTPN13, MGAT4A, ERN1, IL4I1, ANKRD28, TMIGD2" 0.56 1.35 0.94 33 | CD4.c16 IL21+ Tfh "NR3C1, TOX2, TOX, TSHZ2, RBPJ" "CXCL13, IL21, TNFSF8, TNFSF11, TNFSF4, LIF, CD40LG" "IL6ST, CXCR5, IL6R" "GNG4, CD200, NMB, IGFL2, LHFP, CPM, BTLA, FKBP5, PDE7B, ITM2A" 0.23 1.12 1.33 34 | CD4.c17 IFNG+ Tfh/Th1 "ZBED2, ZEB2, ID2, BHLHE40, RBPJ" "CXCL13, CCL4, IFNG, GZMB, CCL3, GZMA, CCL5, CSF2, IL21, FAM3C" "CXCR6, CCR5, CD4, IL2RG, CD74" "LAG3, HAVCR2, PDCD1, KRT86, MYO7A, PTMS, RDH10, CCL4L2, PDE7B, DUSP4" 0 0.26 6.41 35 | CD4.c18 TNFRSF9- Treg "FOXP3, IKZF2, ARID5B, IKZF4" "RTKN2, TIGIT, TBC1D4, FCRL3, CEACAM4, SELL, VAV3, STAM, TTN, FAM19A2" 0.74 0.76 1.38 36 | CD4.c19 S1PR1+ Treg "FOXP3, IKZF2, KLF2, LEF1, KLF3" "IL32, LTB, FLT3LG" "IL10RA, CCR10, CCR4, IL2RA, CD74" "RTKN2, SELL, HLA-DRB1, SAMHD1, TTN, AES, CPNE2, CCDC141, HPGD, PI16" 1.77 0.53 1.13 37 | CD4.c20 TNFRSF9+ Treg "FOXP3, BATF, IKZF2, IKZF4, ZBTB32" "IL32, NAMPT, EBI3, CCL22, LTB, LTA, CSF1, CD70, IL1RN, IL7" "IL2RA, CCR8, IL1R2, IL2RB, CD74" "LAYN, TNFRSF18, TNFRSF9, TIGIT, CTLA4, TNFRSF4, CARD16, LAIR2, TBC1D4, PMAIP1" 0.1 0.32 4.72 38 | CD4.c21 ISG+ Treg "FOXP3, STAT1, IRF7, ETV7, BATF" "IL32, LTA, TNFSF10, IL1RN, LTB, CSF1, NAMPT, IL7, CD70, TNFSF13B" "IL2RA, CCR8, IL1R2, CD74, IL2RB" "IFIT1, OAS1, MX1, ISG15, USP18, IFI6, RSAD2, IFIT3, HERC5, LAMP3" 0.01 0.09 18.83 39 | CD4.c22 ISG+ Th "PLSCR1, IRF7, STAT1, SP100, IFI16" "TNFSF10, TNFSF13B" "IFIT3, IFIT1, RSAD2, IFI44L, MX1, ISG15, IFI6, MX2, IFIT2, CMPK2" 0.35 0.15 5.45 40 | CD4.c23 NME1+CCR4- T "ENO1, HMGA1, SUB1, MEOX1, PHF5A" "MIF, GPI, HMGB1, EBI3, CKLF" IL2RA "ACTB, PFN1, ACTG1, GAPDH, PKM, CFL1, TMSB10, TXN, ARPC1B, CORO1A" 2.88 0.36 0.93 41 | CD4.c24 NME1+CCR4+ T "SUB1, HDAC1, KLF2, ENO1, SCAND1" "IL32, CMTM7, HMGB1, FLT3LG, IL16" "CD74, CCR4, IL2RG, IL6R, IFNAR2" "ACTB, PFN1, ACTG1, TMSB10, CORO1A, COTL1, ARPC1B, CNN2, ARHGDIB, TPM4" 2.59 0.65 0.78 42 | -------------------------------------------------------------------------------- /inst/extdata/build_CellType_Bindea2013_cancer.R: -------------------------------------------------------------------------------- 1 | # Bindea2013 Citation:https://www.sciencedirect.com/science/article/pii/S1074761313004378?via%3Dihub 2 | # Bindea, G., Mlecnik, B., Tosolini, M., Kirilovsky, A., Waldner, M., Obenauf, A. C., ... & Galon, J. (2013). Spatiotemporal dynamics of intratumoral immune cells reveal the immune landscape in human cancer. Immunity, 39(4), 782-795. 3 | # Download Table S1 and modify format: Bindea2013_tableS1_immune.txt 4 | 5 | 6 | ## setwd("./") # working directory is the TimiGP folder 7 | rm(list = ls()) 8 | myinf2 <- "inst/extdata/Bindea2013_tableS1_immune.txt" 9 | myinf4 <- "inst/extdata/CellType_summary.csv" 10 | myoutf1 <- "data/CellType_Bindea2013_cancer.rda" 11 | 12 | 13 | ## Bindea2013 ---- 14 | myset2 <- read.table(myinf2, 15 | header = F, sep = "\t", stringsAsFactors = F) 16 | head(myset2) 17 | myset2 <- myset2[, -3] 18 | colnames(myset2) <- c("CellType", "Gene") 19 | myset2$Dataset <- "Bindea2013" 20 | myset2 <- myset2[, c(3, 1,2)] 21 | head(myset2) 22 | se <- which(duplicated(myset2)) 23 | length(se) #95 24 | myset2 <- myset2[-se, ] 25 | dim(myset2) # 586 3 26 | se <- which(duplicated(myset2$Gene)) 27 | length(se) # 7 28 | myset2[se, ] 29 | dup.gene <- myset2[se, 3] 30 | dup.gene 31 | se <- which(myset2$Gene %in% dup.gene) 32 | se # 38 44 45 55 65 74 115 231 276 283 314 334 579 33 | myset2[se, ] 34 | # don not remove duplicates(little influence) 35 | 36 | # Dataset CellType Gene 37 | # 44 Bindea2013 T cells CD28 remove 38 38 | # 53 Bindea2013 T cells TRA remove 44 39 | # 54 Bindea2013 T cells ITM2A remove 45 40 | # 67 Bindea2013 T helper cells ITM2A 41 | # 77 Bindea2013 T helper cells TRA remove 65 42 | # 87 Bindea2013 T helper cells CD28 43 | # 129 Bindea2013 Tem TRA 44 | # 264 Bindea2013 CD8 T cells APBA2 remove 231 45 | # 315 Bindea2013 Cytotoxic cells APBA2 46 | # 323 Bindea2013 NK cells XCL1 remove 283 47 | # 356 Bindea2013 NK cells IGFBP5 48 | # 381 Bindea2013 NK CD56bright cells XCL1 49 | # 674 Bindea2013 Normal mucosa IGFBP5 remove 579 50 | # myset2 <- myset2[-se[c(1:3, 5, 8, 10, 13)], ] 51 | # sum(duplicated(myset2$Gene)) #0 52 | 53 | 54 | geneset <- myset2 55 | 56 | 57 | 58 | ref <- read.csv(myinf4,header = T) 59 | refxx <- filter(ref,Dataset == "Bindea2013") 60 | refxx <- refxx[,c("Method.Name", "Paper.Name")] 61 | sum(!unique(geneset$CellType) %in% unique(refxx$Paper.Name)) #5 62 | ## unique(geneset$CellType)[!unique(geneset$CellType) %in% unique(refxx$Paper.Name)] 63 | ## pDC & Treg: 1 marker; Th 17: 3 markers; remove 64 | ## Only keep immune gene 65 | ## [1] "Bindea2013_Th17 cells" "Bindea2013_TReg" "Bindea2013_pDC" "Bindea2013_Normal mucosa" "Bindea2013_Blood vessels" "Bindea2013_Lymph vessels" 66 | 67 | sum(!unique(refxx$Paper.Name) %in% unique(geneset$CellType)) #0 68 | 69 | geneset <- merge(geneset,refxx,by.x = "CellType", by.y = "Paper.Name") 70 | 71 | 72 | # "CellType" "Gene" "Dataset" 73 | geneset <- geneset[4:2] 74 | setnames(geneset,old = "Method.Name", new = "CellType") 75 | dim(geneset) # 545 3 76 | 77 | 78 | CellType_Bindea2013_cancer <- geneset 79 | # save(CellType_Bindea2013_cancer, file = myoutf1) 80 | -------------------------------------------------------------------------------- /inst/extdata/build_CellType_Charoentong2017_Bindea2013_Xu2018_Immune.R: -------------------------------------------------------------------------------- 1 | # Charoentong2017 Citation:https://www.sciencedirect.com/science/article/pii/S2211124716317090?via%3Dihub 2 | # Charoentong, P., Finotello, F., Angelova, M., Mayer, C., Efremova, M., Rieder, D., ... & Trajanoski, Z. (2017). Pan-cancer immunogenomic analyses reveal genotype-immunophenotype relationships and predictors of response to checkpoint blockade. Cell reports, 18(1), 248-262. 3 | # Download Table S6 and modify format: Charoentong2017_tableS6_Immune.txt 4 | 5 | 6 | # Bindea2013 Citation:https://www.sciencedirect.com/science/article/pii/S1074761313004378?via%3Dihub 7 | # Bindea, G., Mlecnik, B., Tosolini, M., Kirilovsky, A., Waldner, M., Obenauf, A. C., ... & Galon, J. (2013). Spatiotemporal dynamics of intratumoral immune cells reveal the immune landscape in human cancer. Immunity, 39(4), 782-795. 8 | # Download Table S1 and modify format: Bindea2013_tableS1_immune.txt 9 | 10 | # Xu2018 Citation:https://aacrjournals.org/cancerres/article/78/23/6575/543748/Xu2018-A-Web-Server-for-Resolving-Tumor 11 | # Xu, L., Deng, C., Pang, B., Zhang, X., Liu, W., Liao, G., ... & Li, X. (2018). Xu2018: a web server for resolving tumor immunophenotype profiling. Cancer research, 78(23), 6575-6580. 12 | # Download from http://biocc.hrbmu.edu.cn/Xu2018/download/signature%20annotation.txt: Xu2018_Signature.txt 13 | 14 | 15 | ## setwd("./") # working directory is the TimiGP folder 16 | library(dplyr) 17 | library(data.table) 18 | rm(list = ls()) 19 | myinf1 <- "inst/extdata/Charoentong2017_tableS6_Immune.txt" 20 | myinf2 <- "inst/extdata/Bindea2013_tableS1_immune.txt" 21 | myinf3 <- "inst/extdata/Xu2018_Signature.txt" 22 | myinf4 <- "inst/extdata/CellType_summary.csv" 23 | myoutf1 <- "data/CellType_Charoentong2017_Bindea2013_Xu2018_Immune.rda" 24 | 25 | 26 | ## Charoentong2017 ---- 27 | myset1 <- read.table(myinf1, 28 | header = T, sep = "\t", stringsAsFactors = F) 29 | head(myset1) 30 | myset1 <- myset1[, -3] 31 | colnames(myset1) <- c("Gene", "CellType") 32 | myset1$Dataset <- "Charoentong2017" 33 | myset1 <- myset1[, 3:1] 34 | head(myset1) 35 | sum(duplicated(myset1$Gene)) # 0 36 | 37 | ## Bindea2013 ---- 38 | myset2 <- read.table(myinf2, 39 | header = F, sep = "\t", stringsAsFactors = F) 40 | head(myset2) 41 | myset2 <- myset2[, -3] 42 | colnames(myset2) <- c("CellType", "Gene") 43 | myset2$Dataset <- "Bindea2013" 44 | myset2 <- myset2[, c(3, 1,2)] 45 | head(myset2) 46 | se <- which(duplicated(myset2)) 47 | length(se) #95 48 | myset2 <- myset2[-se, ] 49 | dim(myset2) # 586 3 50 | se <- which(duplicated(myset2$Gene)) 51 | length(se) # 7 52 | myset2[se, ] 53 | dup.gene <- myset2[se, 3] 54 | dup.gene 55 | se <- which(myset2$Gene %in% dup.gene) 56 | se # 38 44 45 55 65 74 115 231 276 283 314 334 579 57 | myset2[se, ] 58 | # don not remove duplicates(little influence) 59 | # If keep mutually exclussive, you can keep the maker of subtype like below)------ 60 | # Dataset CellType Gene 61 | # 44 Bindea2013 T cells CD28 remove 38 62 | # 53 Bindea2013 T cells TRA remove 44 63 | # 54 Bindea2013 T cells ITM2A remove 45 64 | # 67 Bindea2013 T helper cells ITM2A 65 | # 77 Bindea2013 T helper cells TRA remove 65 66 | # 87 Bindea2013 T helper cells CD28 67 | # 129 Bindea2013 Tem TRA 68 | # 264 Bindea2013 CD8 T cells APBA2 remove 231 69 | # 315 Bindea2013 Cytotoxic cells APBA2 70 | # 323 Bindea2013 NK cells XCL1 remove 283 71 | # 356 Bindea2013 NK cells IGFBP5 72 | # 381 Bindea2013 NK CD56bright cells XCL1 73 | # 674 Bindea2013 Normal mucosa IGFBP5 remove 579 74 | # myset2 <- myset2[-se[c(1:3, 5, 8, 10, 13)], ] 75 | # sum(duplicated(myset2$Gene)) #0 76 | se <- which(myset2$CellType == "SW480 cancer cells") 77 | length(se) 78 | myset2_wo_cancer <- myset2[-se, ] 79 | ## Xu2018 ---- 80 | 81 | myset3 <- read.table(myinf3, 82 | header = T, sep = "\t", stringsAsFactors = F) 83 | head(myset3) 84 | myset3 <- myset3[, c(1,4)] 85 | colnames(myset3) <- c("Gene", "CellType") 86 | myset3$Dataset <- "Xu2018" 87 | myset3 <- myset3[, 3:1] 88 | head(myset3) 89 | 90 | se <- which(myset3$CellType != "Multiple") 91 | myset4 <- myset3[se,] 92 | head(myset4) # 0 93 | 94 | se <- which(duplicated(myset4$Gene)) 95 | length(se) # 38 96 | length(se)/nrow(myset4) # 0.4470588 97 | table(myset4$CellType) 98 | ## Did not remove duplicated genes(too many) 99 | ## Some cell type without gene markers if remove them 100 | 101 | ## Combine annotation set(remove multiple in Xu2018) ---- 102 | 103 | geneset <- rbind(myset1, myset2_wo_cancer, myset4) 104 | table(geneset$CellType,geneset$Dataset) 105 | geneset$CellType <- paste0(geneset$Dataset,"_",geneset$CellType) 106 | ##Change cell type name 107 | ref <- read.csv(myinf4,header = T) 108 | refxx <- filter(ref,Dataset == "Charoentong2017"|Dataset == "Bindea2013"|Dataset == "Xu2018") 109 | refxx$Paper.Name <- paste0(refxx$Dataset,"_",refxx$Paper.Name) 110 | refxx <- refxx[,c("Method.Name", "Paper.Name")] 111 | sum(!unique(geneset$CellType) %in% unique(refxx$Paper.Name)) #5 112 | ## unique(geneset$CellType)[!unique(geneset$CellType) %in% unique(refxx$Paper.Name)] 113 | ## pDC & Treg: 1 marker; Th 17: 3 markers; remove 114 | ## Only keep immune gene 115 | ## [1] "Bindea2013_Th17 cells" "Bindea2013_TReg" "Bindea2013_pDC" "Bindea2013_Normal mucosa" "Bindea2013_Blood vessels" "Bindea2013_Lymph vessels" 116 | 117 | sum(!unique(refxx$Paper.Name) %in% unique(geneset$CellType)) #1 118 | # "Bindea2013_SW480 cancer cells"unique(refxx$Paper.Name)[!unique(refxx$Paper.Name) %in% unique(geneset$CellType)] 119 | # "Bindea2013_SW480 cancer cells" 120 | geneset <- merge(geneset,refxx,by.x = "CellType", by.y = "Paper.Name") 121 | 122 | # "CellType" "Gene" "Dataset" 123 | geneset <- geneset[4:2] 124 | setnames(geneset,old = "Method.Name", new = "CellType") 125 | dim(geneset) # 1375 3 126 | 127 | CellType_Charoentong2017_Bindea2013_Xu2018_Immune <- geneset 128 | # save(CellType_Charoentong2017_Bindea2013_Xu2018_Immune, file = myoutf1) 129 | 130 | 131 | -------------------------------------------------------------------------------- /inst/extdata/build_CellType_Newman2015_LM22.R: -------------------------------------------------------------------------------- 1 | # Newman2015 Citation:https://www.nature.com/articles/nmeth.3337 2 | # Newman, A. M., Liu, C. L., Green, M. R., Gentles, A. J., Feng, W., Xu, Y., ... & Alizadeh, A. A. (2015). Robust enumeration of cell subsets from tissue expression profiles. Nature methods, 12(5), 453-457.# Download Table S6 and modify format: Newman2015_tableS6_Immune.txt 3 | # Downloaded from table S1 and modified as: Newman2015_TableS1.txt 4 | 5 | ## setwd("./") # working directory is the TimiGP folder 6 | library(dplyr) 7 | library(data.table) 8 | rm(list = ls()) 9 | myinf1 <- "inst/extdata/Newman2015_TableS1.txt" 10 | myinf2 <- "inst/extdata/Aran2017_TableS3.txt" 11 | myinf2.1 <- "inst/extdata/Aran2017_TableS1.csv" 12 | myinf3 <- "inst/extdata/Luca2021_TableS4.txt" 13 | myinf4 <- "inst/extdata/CellType_summary.csv" 14 | myoutf1 <- "data/CellType_Newman2015_LM22.rda" 15 | 16 | 17 | ## Newman2015 ---- 18 | mydata <- read.table(myinf1, row.names = 1, 19 | header = T, sep = "\t", stringsAsFactors = F) 20 | 21 | myset1 <- data.frame() 22 | for (i in 1:ncol(mydata)){ 23 | se <- which(mydata[i] == 1) 24 | tmp <- data.frame( 25 | CellType = colnames(mydata)[i], 26 | Gene = rownames(mydata)[se], 27 | Dataset = rep( "Newman2015",length(se))) 28 | myset1 <- rbind(myset1,tmp) 29 | } 30 | 31 | 32 | 33 | 34 | ref <- read.csv(myinf4,header = T) 35 | refxx <- filter(ref,Dataset == "Newman2015") 36 | refxx <- refxx[,c("Method.Name", "Paper.Name")] 37 | sum(!unique(myset1$CellType) %in% unique(refxx$Paper.Name)) #0 38 | sum(!unique(refxx$Paper.Name) %in% unique(myset1$CellType))# 39 | 40 | myset1 <- merge(myset1,refxx,by.x = "CellType", by.y = "Paper.Name") 41 | 42 | myset1 <- myset1[c("Method.Name", "Gene", "Dataset" )] 43 | setnames(myset1,old = "Method.Name", new = "CellType") 44 | 45 | CellType_Newman2015_LM22 <- myset1 46 | 47 | #save(CellType_Newman2015_LM22, file = myoutf1) 48 | 49 | 50 | -------------------------------------------------------------------------------- /inst/extdata/build_CellType_Tirosh2016_melanoma_TME.R: -------------------------------------------------------------------------------- 1 | # Tirosh2016 Citation:https://www.science.org/doi/full/10.1126/science.aad0501 2 | # Tirosh, I., Izar, B., Prakadan, S. M., Wadsworth, M. H., Treacy, D., Trombetta, J. J., ... & Garraway, L. A. (2016). Dissecting the multicellular ecosystem of metastatic melanoma by single-cell RNA-seq. Science, 352(6282), 189-196. 3 | # Download Table S3 and modify format: Tirosh2016_tableS3_melanoma.txt 4 | 5 | ## setwd("./") # working directory is the TimiGP folder 6 | library(dplyr) 7 | library(data.table) 8 | rm(list = ls()) 9 | myinf1 <- "inst/extdata/Tirosh2016_tableS3_melanoma.txt" 10 | myinf2 <- "inst/extdata/CellType_summary.csv" 11 | myoutf1 <- "data/CellType_Tirosh2016_melanoma_TME.rda" 12 | 13 | 14 | ## Tirosh2016 ####### 15 | myset1 <- read.table(myinf1, 16 | header = T, sep = "\t", stringsAsFactors = F) 17 | myset1$Dataset <- "Tirosh2016" 18 | 19 | geneset <- myset1[c("Dataset", "CellType" ,"Gene")] 20 | 21 | 22 | ##Change cell type name 23 | ref <- read.csv(myinf2,header = T) 24 | refxx <- filter(ref,Dataset == "Tirosh2016") 25 | refxx <- refxx[,c("Method.Name", "Paper.Name")] 26 | sum(!unique(geneset$CellType) %in% unique(refxx$Paper.Name)) #0 27 | sum(!unique(refxx$Paper.Name) %in% unique(geneset$CellType)) #0 28 | geneset <- merge(geneset,refxx,by.x = "CellType", by.y = "Paper.Name") 29 | 30 | geneset <- geneset[4:2] 31 | setnames(geneset,old = "Method.Name", new = "CellType") 32 | dim(geneset) # 663 3 33 | 34 | table(geneset[1]) 35 | 36 | # B CAF Endo Macrophage Melanoma T 37 | # 31 88 95 92 47 38 38 | 39 | ## save ####### 40 | CellType_Tirosh2016_melanoma_TME <- geneset 41 | # save(CellType_Tirosh2016_melanoma_TME, file = myoutf1) -------------------------------------------------------------------------------- /inst/extdata/build_CellType_Zheng2021_Tcell.R: -------------------------------------------------------------------------------- 1 | # Zheng2021 Citation:https://www.science.org/doi/10.1126/science.abe6474 2 | # Zheng, L., Qin, S., Si, W., Wang, A., Xing, B., Gao, R., ... & Zhang, Z. (2021). Pan-cancer single-cell landscape of tumor-infiltrating T cells. Science, 374(6574), abe6474. 3 | # Download Table S2 and modify format: Zhang2021_tableS2_Tcell.txt 4 | 5 | 6 | ## setwd("./") # working directory is the TimiGP folder 7 | rm(list = ls()) 8 | library(dplyr) 9 | 10 | myinf1 <- "inst/extdata/Zheng2021_tableS2_Tcell.txt" 11 | myoutf1 <- "data/CellType_Zheng2021_Tcell.rda" 12 | 13 | myset1 <- read.table(myinf1,sep = "\t",header = T,stringsAsFactors = F) 14 | myset1 <- myset1[,1:6] 15 | colnames(myset1) 16 | myset1$Gene <- paste(myset1[,3],myset1[,4],myset1[,5],myset1[,6] ,sep= ",") 17 | head(myset1$Gene,1) 18 | myset1 <- myset1[,c(1,2,7)] 19 | myset1$cell <- myset1$meta.cluster %>% strsplit(split = ".c") %>% sapply("[[",1) 20 | 21 | setS2 <- data.frame() 22 | 23 | for (i in 1:nrow(myset1)) { 24 | xx <- strsplit(myset1$Gene[i],split = ",") %>% unlist() %>% 25 | sub(pattern = " ",replacement = "") 26 | xx <- xx[xx!=""] 27 | nn <- length(xx) 28 | setS2 <- rbind(setS2, 29 | data.frame( 30 | Dataset=rep("Zheng2021",nn), 31 | CellType = rep(paste0(myset1$cell[i],"+",myset1$Functional.properties[i]),nn), 32 | Gene=xx, 33 | Cluster = rep(myset1$meta.cluster[i],nn), 34 | Function = rep(myset1$Functional.properties[i],nn) )) 35 | } 36 | 37 | table(setS2$CellType) 38 | length(unique(setS2$Gene)) # 389 39 | 40 | 41 | # Many duplicates --- will not be removed 42 | geneset <- setS2 43 | # Remove duplicates 44 | table(geneset$CellType) 45 | se <- which(duplicated(geneset$Gene)) 46 | dup.gene <- geneset$Gene[se] 47 | length(unique(dup.gene)) # 212 48 | 49 | table(geneset$CellType) 50 | colnames(geneset) 51 | dim(geneset) # 926 5 52 | 53 | geneset <- geneset[c(2,3,1)] 54 | CellType_Zheng2021_Tcell <- geneset 55 | # save(CellType_Zheng2021_Tcell, file = myoutf1) -------------------------------------------------------------------------------- /inst/extdata/build_Immune_Marker_n1293.R: -------------------------------------------------------------------------------- 1 | # Orgnize immune related genes 2 | library(dplyr) 3 | rm(list = ls()) 4 | myinf1 <- "inst/extdata/Charoentong2017_tableS6_Immune.txt" 5 | myinf2 <- "inst/extdata/Bindea2013_tableS1_immune.txt" 6 | myinf3 <- "inst/extdata/Xu2018_Signature.txt" 7 | myoutf1 <- "data/Immune_Marker_n1293.rda" 8 | 9 | 10 | ## Charoentong2017 ---- 11 | myset1 <- read.table(myinf1, 12 | header = T, sep = "\t", stringsAsFactors = F) 13 | head(myset1) 14 | myset1 <- myset1[, -3] 15 | colnames(myset1) <- c("Gene", "CellType") 16 | myset1$Dataset <- "Charoentong2017" 17 | myset1 <- myset1[, 3:1] 18 | 19 | ## Bindea2013 ---- 20 | myset2 <- read.table(myinf2, 21 | header = F, sep = "\t", stringsAsFactors = F) 22 | head(myset2) 23 | myset2 <- myset2[, -3] 24 | colnames(myset2) <- c("CellType", "Gene") 25 | myset2$Dataset <- "Bindea2013" 26 | myset2 <- myset2[, c(3, 1,2)] 27 | 28 | se <- which(myset2$CellType == "SW480 cancer cells" | 29 | myset2$CellType == "Lymph vessels" | 30 | myset2$CellType == "Normal mucosa" | 31 | myset2$CellType == "Blood vessels") 32 | length(se) 33 | myset2 <- myset2[-se, ] 34 | ## Xu2018 ---- 35 | 36 | myset3 <- read.table(myinf3, 37 | header = T, sep = "\t", stringsAsFactors = F) 38 | head(myset3) 39 | myset3 <- myset3[, c(1,4)] 40 | colnames(myset3) <- c("Gene", "CellType") 41 | myset3$Dataset <- "Xu2018" 42 | myset3 <- myset3[, 3:1] 43 | 44 | 45 | 46 | mygen <- unique(c(myset1$Gene,myset2$Gene,myset3$Gene)) 47 | 48 | length(mygen) # 1269 49 | 50 | ## Add some immue gene------------------ 51 | xx <- icg <- c("ADORA2A", "CD276", "VTCN1", "BTLA", "CTLA4", "IDO1", "KIR", "LAG3", "CYBB", "PDCD1", "CD274", "HAVCR2", "SIGLEC7", "VISTA", "VSIR", "C10orf54") 52 | mygen <- unique(c(mygen, xx)) 53 | length(mygen) # 1274 54 | 55 | xx <- imm.inh <- c("CTLA4", "PDCD1", "LAG3", "BTLA", "CD160", "IDO1", "IL10", "IL10RB", "TGFB1", "TGFBR1", "VTCN1", "CD244", "LGALS9", "HAVCR2", "ADORA2A", "TIGIT", "CSF1R", "KIR2DL1", "KIR2DL2", "KIR2DL3", "KDR", "CD96", "PVRL2", "C10orf54") 56 | mygen <- unique(c(mygen, xx)) 57 | length(mygen) # 1277 58 | 59 | xx <- imm.sti <- c("MICA", "MICB", "CD27", "CD274", "CD28", "CD40", "CD40LG", "CD70", "CD80", "CD86", "ICOS", "ICOSLG", "IL6", "IL6R", "PDCD1LG2", "TMEM173", "TNFRSF13B", "TNFRSF13C", "TNFRSF14", "TNFRSF17", "TNFRSF18", "TNFRSF4", "TNFRSF9", "TNFSF13", "TNFSF13B", "TNFSF18", "TNFSF4", "TNFSF9", "TNFSF15", "TNFRSF25", "HHLA2", "TMIGD2", "BTNL2", "CD276", "CD48", "TNFSF14", "TNFRSF8", "PVR", "LTA", "IL2RA", "ENTPD1", "NT5E", "CXCR4", "CXCL12", "KLRK1", "NKG2A", "RAET1E", "ULBP1") 60 | mygen <- unique(c(mygen, xx)) 61 | length(mygen) # 1293 62 | 63 | xx <- imm.oth <- c("GZMA", "PRF1") 64 | mygen <- unique(c(mygen, xx)) 65 | length(mygen) ## 1293 genes 66 | 67 | Immune_Marker_n1293 <- mygen 68 | # save(Immune_Marker_n1293,file = myoutf1) 69 | 70 | -------------------------------------------------------------------------------- /inst/extdata/build_SKCM06_RNA_info.R: -------------------------------------------------------------------------------- 1 | # The Cancer Genome Atlas (TCGA) RNA-seq dataset for skin cutaneous melanoma (SKCM) 2 | # was downloaded from Firehose (https://gdac.broadinstitute.org/). 3 | # This dataset consisted of RSEM normalized gene expression data for 20,501 genes from 473 skin cutaneous melanoma samples. 4 | # Of the SKCM samples, 103 are from primary tumors and 368 are from metastatic tumor samples. 5 | # We used the metastatic tumor samples --- SKCM06 6 | 7 | ## SKCM06 clinical info##### 8 | myinf1 <- "~/TCGA_SKCM/SKCM_RNAseqv2_ALL_Symbol.rda" 9 | myinf2 <- "~/TCGA_SKCM/SKCM_Clincial_info.txt" 10 | 11 | myoutf1 <- "./data/SKCM06rna.rda" 12 | myoutf2 <- "data/SKCM06info.rda" 13 | ## load SKCM06 RNA 14 | load(myinf1) 15 | rna <- mydata 16 | xx <- as.numeric(substr(colnames(rna), 14, 15)) 17 | se <- which(xx==6) ## metastatic 18 | length(se) # 368 samples 19 | rna <- rna[,se] 20 | dim(rna) # 20501 368 21 | colnames(rna) <- substr(colnames(rna), 1, 12) 22 | 23 | SKCM06rna <- rna 24 | # save(SKCM06rna,file = myoutf1) 25 | 26 | ## load clinical info 27 | info <- read.table(myinf2, sep="\t", header=T, row.names=1, quote="") 28 | head(info) 29 | colnames(info) 30 | 31 | se <- c("vital_status", "gender", "stage_event.pathologic_stage", "days_to_death", "days_to_last_followup", "age_at_initial_pathologic_diagnosis", "race_list.race", "tumor_tissue_site") 32 | info <- info[,se] 33 | 34 | xx <- info[, "vital_status"] 35 | event <- ifelse(xx=="dead", 1, 0) 36 | event[is.na(xx)] <- NA 37 | xx <- info[, "days_to_death"] 38 | time <- ifelse(!is.na(xx), xx, info[, "days_to_last_followup"]) 39 | time <- as.numeric(time) 40 | SKCM06info <- data.frame( event, time) 41 | rownames(SKCM06info ) <- rownames(info) 42 | 43 | comSam <- intersect(row.names(SKCM06info), colnames(rna)) 44 | 45 | 46 | SKCM06info <- SKCM06info[comSam,] 47 | # save(SKCM06info ,file = myoutf2) 48 | -------------------------------------------------------------------------------- /inst/extdata/build_TNBCaPD1_RNA_info.R: -------------------------------------------------------------------------------- 1 | # Data source ################################################################## 2 | # The microarray dataset GSE194040 for Triple-negative breast cancer (TNBC) 3 | # was downloaded from GEO (https://www.ncbi.nlm.nih.gov/geo/download/?acc=GSE194040&format=file&file=GSE194040%5FISPY2ResID%5FAgilentGeneExp%5F990%5FFrshFrzn%5FmeanCol%5FgeneLevel%5Fn988%2Etxt%2Egz). 4 | # The file was decompressed and saved to `myinf1` 5 | 6 | # The corresponding clinical info 7 | # was downloaded from GEO (https://ftp.ncbi.nlm.nih.gov/geo/series/GSE194nnn/GSE194040/soft/GSE194040_family.soft.gz) 8 | # The file was decompressed and saved to 9 | # "./Breast_Cancer/I-SPY_GSE194040/raw/GSE194040_family.soft" 10 | 11 | # The clinical info was preprocessed with below shell script 12 | # And saved to `myinf2` 13 | # sh Extract_clinical_info_from_familysort.sh --> 14 | #!/bin/sh 15 | # cat *family.soft |grep ! |more 16 | # cat *family.soft |grep SAMPLE|cut -d "=" -f 2|sed s#"^ "##g > sample_tmp.txt 17 | # cat *family.soft |grep "patient id:"|cut -d ":" -f 2|sed s#"^ "##g > title_tmp.txt 18 | # cat *family.soft |grep Sample_source_name_ch1|cut -d "=" -f 2|sed s#"^ "##g > tissue_tmp.txt 19 | # cat *family.soft |grep "her2:"|cut -d ":" -f 2|sed s#"^ "##g > her2_tmp.txt 20 | # cat *family.soft |grep "hr:"|cut -d ":" -f 2|sed s#"^ "##g > hr_tmp.txt 21 | # cat *family.soft |grep "pcr:"|cut -d ":" -f 2|sed s#"^ "##g > pcr_tmp.txt 22 | # cat *family.soft |grep "mp:"|cut -d ":" -f 2|sed s#"^ "##g > mp_tmp.txt 23 | # cat *family.soft |grep "arm:"|cut -d ":" -f 2|sed s#"^ "##g > arm_tmp.txt 24 | # ls *tmp.txt|cut -d "_" -f 1| sed ':a;N;$!ba;s#\n#\t#g' > Clinical_info.txt 25 | # paste -d "\t" *tmp.txt >> Clinical_info.txt 26 | # mv Clinical_info.txt ../ 27 | # rm *tmp.txt 28 | 29 | # clear workspace and load libraries 30 | rm(list = ls()) 31 | library(dplyr) 32 | library(stringr) 33 | library(data.table) 34 | library(tibble) 35 | # Filter data ################################################################ 36 | myinf1 <- "./Breast_Cancer/I-SPY_GSE194040/raw/GSE194040_ISPY2ResID_AgilentGeneExp_990_FrshFrzn_meanCol_geneLevel_n988.txt" 37 | myinf2 <- "./Breast_Cancer/I-SPY_GSE194040/Clinical_info.txt" 38 | 39 | myoutf1 <- "./data/TNBCaPD1rna.rda" 40 | myoutf2 <- "data/TNBCaPD1info.rda" 41 | 42 | # rna----------------------------------------------------------------------- 43 | rna <- read.table(myinf1,sep = "\t",header = T,row.names = 1) 44 | 45 | # info---------------------------------------------------------------------- 46 | info <- read.table(myinf2,sep = "\t",header = T) 47 | 48 | table(info$pcr, exclude = F) # NA 1 drop 49 | 50 | # Preprocess the clinical information 51 | info <- info %>% 52 | mutate(rownames = paste0("X",title)) %>% 53 | filter(rownames %in% colnames(rna)) %>% 54 | filter(!is.na(pcr)) %>% # remove unknown treatment response 55 | filter(arm == "Paclitaxel + Pembrolizumab") %>% # select the treatment 56 | filter(her2 == 0 & hr == 0) %>% # filter TNBC 57 | mutate(Response = pcr) %>% 58 | column_to_rownames(var = "rownames") %>% 59 | select( "Response" ) 60 | 61 | # filter the rna samples 62 | rna <- rna[ rownames(info)] 63 | 64 | all(rownames(info) == colnames(rna)) # T 65 | 66 | table(info$Response, exclude = F) 67 | # 0 1 68 | # 13 13 69 | 70 | # Save data ################################################################ 71 | TNBCaPD1rna <- rna 72 | TNBCaPD1info <- info 73 | # save(TNBCaPD1rna ,file = myoutf1) 74 | # save(TNBCaPD1info ,file = myoutf2) 75 | -------------------------------------------------------------------------------- /inst/extdata/build_sysdata.R: -------------------------------------------------------------------------------- 1 | # sysdata are those markers 2 | ## setwd("./") # working directory is the TimiGP folder 3 | 4 | rm(list = ls()) 5 | 6 | myinf1 <- "data/CellType_Charoentong2017_Bindea2013_Xu2018_Immune.rda" 7 | myinf2 <- "data/CellType_Tirosh2016_melanoma_TME.rda" 8 | myinf3 <- "data/CellType_Zheng2021_Tcell.rda" 9 | myinf4 <- "data/CellType_Bindea2013_cancer.rda" 10 | myinf5 <- "data/CellType_Newman2015_LM22.rda" 11 | 12 | 13 | load(myinf1) 14 | load(myinf2) 15 | load(myinf3) 16 | load(myinf4) 17 | load(myinf5) 18 | 19 | Ann_Immune <- CellType_Charoentong2017_Bindea2013_Xu2018_Immune 20 | Ann_melanoma_TME <- CellType_Tirosh2016_melanoma_TME 21 | Ann_Tcell <-CellType_Zheng2021_Tcell 22 | Ann_Bindea2013_Cancer <- CellType_Bindea2013_cancer 23 | Ann_LM22 <- CellType_Newman2015_LM22 24 | # save(Ann_Immune, Ann_melanoma_TME,Ann_Tcell, Ann_Bindea2013_Cancer,Ann_LM22, file = "R/sysdata.rda") -------------------------------------------------------------------------------- /man/Bindea2013c_COX_MP_SKCM06.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{Bindea2013c_COX_MP_SKCM06} 5 | \alias{Bindea2013c_COX_MP_SKCM06} 6 | \title{COX regression Results from function TimiCOX with cell type meaker annotated by Bindea2013_cancer} 7 | \format{ 8 | A data frame with 110215 rows and 3 variables: 9 | \describe{ 10 | \item{Row name}{Marker pair} 11 | \item{HR}{Hazard.Ratio} 12 | \item{PV}{P-Value} 13 | \item{QV}{Adjust P-value} 14 | } 15 | } 16 | \source{ 17 | intermediate result generated from function TimiCOX 18 | } 19 | \usage{ 20 | data(Bindea2013c_COX_MP_SKCM06) 21 | } 22 | \description{ 23 | An intermediate result generated from function TimiCOX 24 | that reveals the association between each marker pairs and favorable prognosis. 25 | } 26 | \keyword{intermediate} 27 | \keyword{result} 28 | -------------------------------------------------------------------------------- /man/Bindea2013c_enrich.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{Bindea2013c_enrich} 5 | \alias{Bindea2013c_enrich} 6 | \title{Cell Interaction Enrichment from function TimiEnrich 7 | with cell type meaker annotated by Bindea2013_cancer} 8 | \format{ 9 | a data frame of enrichment result 10 | generated from TimiEnrich and TimiPermFDR: 11 | \describe{ 12 | \item{Index}{A numeric vector used to specify which cell pair would be used in visualization} 13 | \item{Rank}{A rank of cell interaction according to Adjust. P-value} 14 | \item{Cell.Interaction}{Cell Interaction, e.g. Cell A_Cell B} 15 | \item{Favorable.Cell.Type}{In the cell pair A_B, the first cell A} 16 | \item{Unfavorable.Cell.Type}{In the cell pair A_B, the second cell B} 17 | \item{No.Total.IMGP}{The total number of marker pairs in the cell pair annotation} 18 | \item{No.Shared.IMGP}{The number of marker pairs shared by query pairs and annotation} 19 | \item{Enrichment.Ratio}{Enrichment Ratio} 20 | \item{P.Value}{P. value} 21 | \item{Adjust.P.Value}{Adjust.P.Value} 22 | \item{Permutation.FDR}{FDR calculated from permutation tests by shuffling cell-type markers} 23 | \item{Shared.IMGP}{The marker pairs shared by query pairs and annotation} 24 | \item{Total.IMGP}{The marker pairs in the annotation} 25 | } 26 | } 27 | \source{ 28 | example result generated from function TimiEnrich(example/example01_Bindea2013_Cancer.R) 29 | } 30 | \usage{ 31 | data(Bindea2013c_enrich) 32 | } 33 | \description{ 34 | An example result of cell interaction enrichment generated from function TimiEnrich 35 | } 36 | \keyword{example} 37 | \keyword{result} 38 | -------------------------------------------------------------------------------- /man/CellType_Bindea2013_cancer.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{CellType_Bindea2013_cancer} 5 | \alias{CellType_Bindea2013_cancer} 6 | \title{Cell Type generated from Bindea2013 with cancer cells} 7 | \format{ 8 | A data frame with 545 rows and 3 variables: 9 | \describe{ 10 | \item{CellType}{Immune cell type and cancer cell type} 11 | \item{Gene}{Marker gene of the cell type} 12 | \item{Dataset}{The source of the annotation} 13 | } 14 | } 15 | \source{ 16 | Modification can be found in inst/extdata/build_CellType_Bindea2013_cancer.R 17 | } 18 | \usage{ 19 | data(CellType_Bindea2013_cancer) 20 | } 21 | \description{ 22 | A dataset containing the cell type and markers annotated by Bindea2013 23 | } 24 | \references{ 25 | Bindea, G., Mlecnik, B., Tosolini, M., Kirilovsky, A., Waldner, M., 26 | Obenauf, A. C., ... & Galon, J. (2013). Spatiotemporal dynamics of intratumoral 27 | immune cells reveal the immune landscape in human cancer. Immunity, 39(4), 782-795. 28 | } 29 | \keyword{datasets} 30 | -------------------------------------------------------------------------------- /man/CellType_Charoentong2017_Bindea2013_Xu2018_Immune.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{CellType_Charoentong2017_Bindea2013_Xu2018_Immune} 5 | \alias{CellType_Charoentong2017_Bindea2013_Xu2018_Immune} 6 | \title{Immune Cell Type generated from Charoentong2017, Bindea2013, Xu2018} 7 | \format{ 8 | A data frame with 1375 rows and 3 variables: 9 | \describe{ 10 | \item{CellType}{Immune cell type} 11 | \item{Gene}{Marker gene of the cell type} 12 | \item{Dataset}{The source of the annotation} 13 | } 14 | } 15 | \source{ 16 | Modification can be found in inst/extdata/build_CellType_Charoentong2017_Bindea2013_Xu2018_Immune.R 17 | } 18 | \usage{ 19 | data(CellType_Charoentong2017_Bindea2013_Xu2018_Immune) 20 | } 21 | \description{ 22 | A dataset containing the cell type and markers annotated by Charoentong2017, Bindea2013, Xu2018 23 | } 24 | \references{ 25 | Charoentong, P., Finotello, F., Angelova, M., Mayer, C., Efremova, M., Rieder, D., ... & Trajanoski, Z. (2017). Pan-cancer immunogenomic analyses reveal genotype-immunophenotype relationships and predictors of response to checkpoint blockade. Cell reports, 18(1), 248-262. 26 | 27 | Bindea, G., Mlecnik, B., Tosolini, M., Kirilovsky, A., Waldner, M., Obenauf, A. C., ... & Galon, J. (2013). Spatiotemporal dynamics of intratumoral immune cells reveal the immune landscape in human cancer. Immunity, 39(4), 782-795. 28 | 29 | Xu, L., Deng, C., Pang, B., Zhang, X., Liu, W., Liao, G., ... & Li, X. (2018). Xu2018: a web server for resolving tumor immunophenotype profiling. Cancer research, 78(23), 6575-6580. 30 | } 31 | \keyword{datasets} 32 | -------------------------------------------------------------------------------- /man/CellType_Newman2015_LM22.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{CellType_Newman2015_LM22} 5 | \alias{CellType_Newman2015_LM22} 6 | \title{Immune Cell Type generated from LM22} 7 | \format{ 8 | A data frame with 1140 rows and 3 variables: 9 | \describe{ 10 | \item{CellType}{Immune cell type} 11 | \item{Gene}{Marker gene of the cell type} 12 | \item{Dataset}{The source of the annotation} 13 | } 14 | } 15 | \source{ 16 | Modification can be found in inst/extdata/build_CellType_Newman2015_LM22.R 17 | } 18 | \usage{ 19 | data(CellType_Newman2015_LM22) 20 | } 21 | \description{ 22 | A dataset containing the cell type and markers annotated by LM22, 23 | which is the cell-type signature of CIBERSORT and CIBERSORTx. 24 | } 25 | \references{ 26 | Newman, A. M., Liu, C. L., Green, M. R., Gentles, A. J., Feng, W., Xu, Y., ... & Alizadeh, A. A. (2015). Robust enumeration of cell subsets from tissue expression profiles. Nature methods, 12(5), 453-457. 27 | } 28 | \keyword{datasets} 29 | -------------------------------------------------------------------------------- /man/CellType_TNBC_aPDL1.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{CellType_TNBC_aPDL1} 5 | \alias{CellType_TNBC_aPDL1} 6 | \title{Cell Type customized for TNBC (anti-PD1/PD-L1)} 7 | \format{ 8 | A data frame with 449 rows and 3 variables: 9 | \describe{ 10 | \item{CellType}{Immune cell type} 11 | \item{Gene}{Marker gene of the cell type} 12 | \item{Dataset}{The source of the annotation} 13 | } 14 | } 15 | \source{ 16 | For more details, please refer: https://github.com/CSkylarL/MSofTimiGP-Response/blob/master/Fig1/code/Fig1.script2_generate_TimiGP_markers.R 17 | } 18 | \usage{ 19 | data(CellType_TNBC_aPDL1) 20 | } 21 | \description{ 22 | A dataset containing the cell type and markers customized for 23 | Triple-negative breast cancer (TNBC) cohorts 24 | treated with anti-PD1/PD-L1 therapy. 25 | This cell type annotation generated from single cell RNA-seq (GSE169246) 26 | and it includes 11 immune cell types consistent with 27 | the imaging mass cytometry (IMC) (zenodo.7990870). 28 | } 29 | \references{ 30 | Li C1,, HongW, Reuben A,Wang L, Anirban M, Zhang J, Cheng C. TimiGP-Response Module: Illustrates the pan-cancer immune landscape associated with response to immunotherapy. bioRxiv. (2024) 31 | } 32 | \keyword{datasets} 33 | -------------------------------------------------------------------------------- /man/CellType_Tirosh2016_melanoma_TME.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{CellType_Tirosh2016_melanoma_TME} 5 | \alias{CellType_Tirosh2016_melanoma_TME} 6 | \title{Cell Type in melanoma microenvironment generated from Hughes2020 and Tirosh2016 with cancer cells} 7 | \format{ 8 | A data frame with 391 rows and 3 variables: 9 | \describe{ 10 | \item{CellType}{Immune cell type, skin cell type and cancer cell type} 11 | \item{Gene}{Marker gene of the cell type} 12 | \item{Dataset}{The source of the annotation} 13 | } 14 | } 15 | \source{ 16 | Modification can be found in inst/extdata/build_CellType_Tirosh2016_melanoma_TME.R 17 | } 18 | \usage{ 19 | data(CellType_Tirosh2016_melanoma_TME) 20 | } 21 | \description{ 22 | A dataset containing the cell type and markers annotated by Tirosh2016 23 | } 24 | \references{ 25 | Tirosh, I., Izar, B., Prakadan, S. M., Wadsworth, M. H., Treacy, D., Trombetta, J. J., ... & Garraway, L. A. (2016). Dissecting the multicellular ecosystem of metastatic melanoma by single-cell RNA-seq. Science, 352(6282), 189-196. 26 | } 27 | \keyword{datasets} 28 | -------------------------------------------------------------------------------- /man/CellType_Zheng2021_Tcell.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{CellType_Zheng2021_Tcell} 5 | \alias{CellType_Zheng2021_Tcell} 6 | \title{T Cell Subtypes generated from Zheng2021} 7 | \format{ 8 | A data frame with 926 rows and 3 variables: 9 | \describe{ 10 | \item{CellType}{T cell subtype} 11 | \item{Gene}{Marker gene of the cell type} 12 | \item{Dataset}{The source of the annotation} 13 | } 14 | } 15 | \source{ 16 | Modification can be found in inst/extdata/build_CellType_Zheng2021_Tcell.R 17 | } 18 | \usage{ 19 | data(CellType_Zheng2021_Tcell) 20 | } 21 | \description{ 22 | A dataset containing the cell type and markers annotated by Zheng2021 23 | } 24 | \references{ 25 | Zheng, L., Qin, S., Si, W., Wang, A., Xing, B., Gao, R., ... & Zhang, Z. (2021). Pan-cancer single-cell landscape of tumor-infiltrating T cells. Science, 374(6574), abe6474. 26 | } 27 | \keyword{datasets} 28 | -------------------------------------------------------------------------------- /man/Immune_Marker_n1293.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{Immune_Marker_n1293} 5 | \alias{Immune_Marker_n1293} 6 | \title{Immune markers generated from Charoentong2017, Bindea2013, Xu2018 and classic markers} 7 | \format{ 8 | A vector of 1293 immune markers 9 | } 10 | \source{ 11 | Modification can be found in inst/extdata/build_Immune_Marker_n1293.R 12 | } 13 | \usage{ 14 | data(Immune_Marker_n1293) 15 | } 16 | \description{ 17 | A dataset containing the immune markers annotated by Charoentong2017, Bindea2013, Xu2018 18 | and additional classic immune inhibitors, stimulators and checkpoints. 19 | } 20 | \references{ 21 | Charoentong, P., Finotello, F., Angelova, M., Mayer, C., Efremova, M., Rieder, D., ... & Trajanoski, Z. (2017). Pan-cancer immunogenomic analyses reveal genotype-immunophenotype relationships and predictors of response to checkpoint blockade. Cell reports, 18(1), 248-262. 22 | 23 | Bindea, G., Mlecnik, B., Tosolini, M., Kirilovsky, A., Waldner, M., Obenauf, A. C., ... & Galon, J. (2013). Spatiotemporal dynamics of intratumoral immune cells reveal the immune landscape in human cancer. Immunity, 39(4), 782-795. 24 | 25 | Xu, L., Deng, C., Pang, B., Zhang, X., Liu, W., Liao, G., ... & Li, X. (2018). Xu2018: a web server for resolving tumor immunophenotype profiling. Cancer research, 78(23), 6575-6580. 26 | } 27 | \keyword{datasets} 28 | -------------------------------------------------------------------------------- /man/SKCM06info.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{SKCM06info} 5 | \alias{SKCM06info} 6 | \title{TCGA metastatic melanoma(SKCM06) clinical infomation} 7 | \format{ 8 | A data frame with 368 rows and 2 variables: 9 | \describe{ 10 | \item{row}{Patient ID} 11 | \item{column}{Clinical information, including event(death) and time(day) to event} 12 | } 13 | } 14 | \source{ 15 | Modification can be found in inst/extdata/build_SKCM06_RNA_info.R 16 | } 17 | \usage{ 18 | data(SKCM06info) 19 | } 20 | \description{ 21 | A dataset containing survival statistic of 368 patients. 22 | } 23 | \references{ 24 | \url{"https://gdac.broadinstitute.org/"} 25 | } 26 | \keyword{datasets} 27 | -------------------------------------------------------------------------------- /man/SKCM06rna.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{SKCM06rna} 5 | \alias{SKCM06rna} 6 | \title{TCGA metastatic melanoma(SKCM06) RNA expression} 7 | \format{ 8 | A data frame with 20501 rows and 368 variables: 9 | \describe{ 10 | \item{row}{Gene} 11 | \item{column}{Sample(patient) ID} 12 | } 13 | } 14 | \source{ 15 | Modification can be found in inst/extdata/build_SKCM06_RNA_info.R 16 | } 17 | \usage{ 18 | data(SKCM06rna) 19 | } 20 | \description{ 21 | A dataset containing 20,501 genes from 368 metastatic melanoma samples. 22 | } 23 | \references{ 24 | \url{"https://gdac.broadinstitute.org/"} 25 | } 26 | \keyword{datasets} 27 | -------------------------------------------------------------------------------- /man/TNBCaPD1info.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{TNBCaPD1info} 5 | \alias{TNBCaPD1info} 6 | \title{GSE194040 TNBC chemoimmunotherapy cohort therapy response infomation} 7 | \format{ 8 | A data frame with 26 rows and 1 variables: 9 | \describe{ 10 | \item{row}{Patient ID} 11 | \item{column}{Response: 1=responder, 0=non-responder } 12 | } 13 | } 14 | \source{ 15 | Codes can be found in inst/extdata/build_TNBCaPD1_RNA_info.R 16 | } 17 | \usage{ 18 | data(TNBCaPD1info) 19 | } 20 | \description{ 21 | A dataset containing therapy response from 26 22 | Triple-negative breast cancer (TNBC) patients, 23 | treated with the combination of anti-PD1 immunotherapy and chemotherpay 24 | } 25 | \references{ 26 | \url{"https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE194040"} 27 | } 28 | \keyword{datasets} 29 | -------------------------------------------------------------------------------- /man/TNBCaPD1rna.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{TNBCaPD1rna} 5 | \alias{TNBCaPD1rna} 6 | \title{GSE194040 TNBC chemoimmunotherapy cohort microarray expression} 7 | \format{ 8 | A data frame with 19,134 rows and 26 variables: 9 | \describe{ 10 | \item{row}{Gene} 11 | \item{column}{Sample(patient) ID} 12 | } 13 | } 14 | \source{ 15 | Codes can be found in inst/extdata/build_TNBCaPD1_RNA_info.R 16 | } 17 | \usage{ 18 | data(TNBCaPD1rna) 19 | } 20 | \description{ 21 | A dataset containing 19,134 genes from 26 22 | Triple-negative breast cancer (TNBC) patients, 23 | treated with the combination of anti-PD1 immunotherapy and chemotherpay 24 | } 25 | \references{ 26 | \url{"https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE194040"} 27 | } 28 | \keyword{datasets} 29 | -------------------------------------------------------------------------------- /man/TimiBG.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Enrich.R 3 | \name{TimiBG} 4 | \alias{TimiBG} 5 | \title{Generate marker pair background} 6 | \usage{ 7 | TimiBG(marker.pair = NULL) 8 | } 9 | \arguments{ 10 | \item{marker.pair}{a vector of marker pairs connected by "_"} 11 | } 12 | \value{ 13 | A vector of background gene pairs 14 | } 15 | \description{ 16 | Given a gene pair A_B, it will generate 17 | the background gene pairs A_B and B_A 18 | } 19 | \examples{ 20 | \dontrun{ 21 | data(Bindea2013c_COX_MP_SKCM06) 22 | cox_res <- Bindea2013c_COX_MP_SKCM06 23 | background <- TimiBG(marker.pair = row.names(cox_res)) 24 | } 25 | } 26 | \author{ 27 | Chenyang Skylar Li 28 | } 29 | -------------------------------------------------------------------------------- /man/TimiCOX.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Cox.R 3 | \name{TimiCOX} 4 | \alias{TimiCOX} 5 | \title{Find marker pairs associated with favorable prognosis} 6 | \usage{ 7 | TimiCOX(mps = NULL, info = NULL, p.adj = "BH", parallel = FALSE, core = 1) 8 | } 9 | \arguments{ 10 | \item{mps}{a matrix of Marker Pair Score} 11 | 12 | \item{info}{a data.frame in which the 1st column is event 13 | and the 2nd column is days-to-event.} 14 | 15 | \item{p.adj}{p.adjust.methods. 16 | One of "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none". 17 | The default value is "BH".} 18 | 19 | \item{parallel}{a logical value. If TRUE, enable parallel computing. 20 | The default value if FALSE} 21 | 22 | \item{core}{a numeric value shows the number of cores for parallel execution. 23 | The default value is 1.} 24 | } 25 | \value{ 26 | A list of two results: 27 | 1. Result of cox regression(cox_res) 28 | (HR: Hazard.Ratio,PV: P-Value,QV: Adjust P-value). 29 | 2. modified marker pair score(mps) 30 | } 31 | \description{ 32 | Perform univariate cox regression that fits each marker pair as a variable. 33 | If a Pair A_B associated with poor prognosis(HR > 1), even not significant, 34 | it will be changed to B_A and reverse its value in the matrix of pair 35 | } 36 | \examples{ 37 | \dontrun{ 38 | data("SKCM06info") 39 | data("SKCM06rna") 40 | data("Immune_Marker_n1293") 41 | info <- TimiCheckEvent(SKCM06info) 42 | rna <- TimiPrePropress(gene = Immune_Marker_n1293,rna = SKCM06rna,cohort = rownames(info)) 43 | mps <- TimiGenePair(rna) 44 | dim(mps) 45 | # TimiCOX 46 | res <- TimiCOX(mps = mps,info = info,p.adj = "BH") 47 | mps <- res[["mps"]] 48 | cox_res <- res[["cox_res"]] 49 | } 50 | } 51 | \author{ 52 | Chenyang Skylar Li 53 | } 54 | -------------------------------------------------------------------------------- /man/TimiCellChord.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ChordDiagram.R 3 | \name{TimiCellChord} 4 | \alias{TimiCellChord} 5 | \title{Chord diagram of Cell Interaction} 6 | \usage{ 7 | TimiCellChord( 8 | resdata = NULL, 9 | select = NULL, 10 | dataset = NULL, 11 | group = NULL, 12 | color = NULL, 13 | condition = "Adjust.P.Value", 14 | cutoff = 0.05 15 | ) 16 | } 17 | \arguments{ 18 | \item{resdata}{TimiGP enrichment result generated from TimiEnrich} 19 | 20 | \item{select}{A numeric vector of selected cell interactions according to "Index" column in resdata. 21 | Default selection is all cell-cell interactions(adjusted p value < 0.05).} 22 | 23 | \item{dataset}{A value in one of 24 | c("Bindea2013","Bindea2013_Cancer","Charoentong2017", "Xu2018" 25 | ,"Newman2015", 26 | "Tirosh2016","Zheng2021","Other"). 27 | The first four options include default group and color settings. 28 | If you use other dataset or want to change group and colors, 29 | please choose "Other".} 30 | 31 | \item{group}{A vector of self-defined cell groups, 32 | whose names are the all favorable and unfavorable cells types in selection.} 33 | 34 | \item{color}{A vector of self-defined cell colors, 35 | whose names are the all favorable and unfavorable cells types in selection.} 36 | 37 | \item{condition}{A value in one of 38 | c("P.Value","Adjust.P.Value","Permutation.FDR"), 39 | which is the column name of resdata. 40 | The default value is the "Adjust.P.Value".} 41 | 42 | \item{cutoff}{A cutoff of condition used to filter cell interactions. 43 | The default cutoff is 0.05.} 44 | } 45 | \value{ 46 | Chord diagram of Cell Interaction 47 | } 48 | \description{ 49 | Chord diagram reveals the cell-cell interaction network. 50 | The arrow points from favorable cell type A to unfavorable cell type B, 51 | which denotes that function of A greater than B associated with a good prognosis. 52 | The width of the arrow represents -log10(Adjust.P.Value),namely, 53 | the wider the arrow is, the smaller the adjusted p-value is. 54 | } 55 | \examples{ 56 | \dontrun{ 57 | data("Bindea2013c_enrich") 58 | res <- Bindea2013c_enrich 59 | TimiCellChord(resdata = res,dataset = "Bindea2013_Cancer") 60 | TimiCellChord(resdata = res,dataset = "Bindea2013_Cancer",select = 1:10) 61 | 62 | } 63 | } 64 | \author{ 65 | Chenyang Skylar Li 66 | } 67 | -------------------------------------------------------------------------------- /man/TimiCellNetwork.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Network.R 3 | \name{TimiCellNetwork} 4 | \alias{TimiCellNetwork} 5 | \title{Generate cell network files for Cytoscape} 6 | \usage{ 7 | TimiCellNetwork( 8 | resdata = NULL, 9 | select = NULL, 10 | dataset = NULL, 11 | group = NULL, 12 | geneset = NULL, 13 | condition = "Adjust.P.Value", 14 | cutoff = 0.05, 15 | export = TRUE, 16 | path = NULL 17 | ) 18 | } 19 | \arguments{ 20 | \item{resdata}{TimiGP enrichment result generated from TimiEnrich} 21 | 22 | \item{select}{A numeric vector of selected cell interactions according to "Index" column in resdata. 23 | Default selection is all cell-cell interactions(adjusted p value < 0.05).} 24 | 25 | \item{dataset}{A value in one of 26 | c("Bindea2013","Bindea2013_Cancer", 27 | "Charoentong2017", "Xu2018", 28 | "Newman2015", 29 | "Tirosh2016","Zheng2021","Other") 30 | The first 7 options include default group settings. 31 | If you use other dataset or want to change group, 32 | please choose "Other".} 33 | 34 | \item{group}{A vector of self-defined cell groups, 35 | whose names are the all favorable and unfavorable cells types in selection.} 36 | 37 | \item{geneset}{A data.frame of cell markers, 38 | in which the 1st is cell type, 39 | the 2nd column is the marker gene 40 | and the 3rd column is the name of the dataset(optional)} 41 | 42 | \item{condition}{A value in one of 43 | c("P.Value","Adjust.P.Value","Permutation.FDR"), 44 | which is the column name of resdata. 45 | The default value is the "Adjust.P.Value".} 46 | 47 | \item{cutoff}{A cutoff of condition used to filter cell interactions. 48 | The default cutoff is 0.05.} 49 | 50 | \item{export}{A logical value. If TRUE, it will generate network files 51 | for Cytoscape analysis. The default value is TRUE.} 52 | 53 | \item{path}{A directory to export the network files when "export = TRUE".} 54 | } 55 | \value{ 56 | A list of network required files(network,node,edge) 57 | } 58 | \description{ 59 | It generates three files that can be used to build network in Cytoscape: 60 | 1. network files: simple interaction file (cell_network.sif); 61 | 2. node attributes (cell_node.txt); 62 | 3. edge attributes (cell_edge.txt). 63 | The function also returns a list of above files that can be modified in R. 64 | } 65 | \examples{ 66 | \dontrun{ 67 | data("Bindea2013c_enrich") 68 | res <- Bindea2013c_enrich 69 | NET <- TimiCellNetwork(resdata = res,dataset = "Bindea2013_Cancer",export=T,path="./") 70 | } 71 | } 72 | \author{ 73 | Chenyang Skylar Li 74 | } 75 | -------------------------------------------------------------------------------- /man/TimiCellPair.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Pairwise.R 3 | \name{TimiCellPair} 4 | \alias{TimiCellPair} 5 | \title{Generate cell pair representing potential interaction using 6 | the corresponding marker pair annotation} 7 | \usage{ 8 | TimiCellPair(geneset = NULL, dataset = NULL, core = 1) 9 | } 10 | \arguments{ 11 | \item{geneset}{a data.frame of cell markers, 12 | in which the 1st column is cell type, 13 | the 2nd column is the marker gene 14 | and the 3rd column is the name of the dataset (optional)} 15 | 16 | \item{dataset}{specified at least 1 dataset occured in the 3rd column of geneset} 17 | 18 | \item{core}{a numeric value shows the number of cores 19 | to use for parallel execution. The default value is 1.} 20 | } 21 | \value{ 22 | A dataframe of Cell pair and the corresponding marker pair 23 | } 24 | \description{ 25 | Given any two different cell types, 26 | Cell A has markers a1 and a2 and cell B has markers b1 and b2. 27 | Cell pair A_B includes marker pairs: a1_b1, a1_b2, a2_b1, a2_b2; 28 | Cell pair B_A includes marker pairs: b1_a1, b1_a2, b2_a1, b2_a2 29 | } 30 | \examples{ 31 | \dontrun{ 32 | data(CellType_Galon2013_cancer) 33 | geneset <- CellType_Galon2013_cancer 34 | cell_pair <- TimiCellPair(geneset = geneset,core = 2) 35 | } 36 | } 37 | \author{ 38 | Chenyang Skylar Li 39 | } 40 | -------------------------------------------------------------------------------- /man/TimiCheckEvent.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Preprocess.R 3 | \name{TimiCheckEvent} 4 | \alias{TimiCheckEvent} 5 | \title{Check Clinical Info} 6 | \usage{ 7 | TimiCheckEvent(info = NULL) 8 | } 9 | \arguments{ 10 | \item{info}{a data.frame in which the 1st column is event 11 | and the 2nd column is days-to-event.} 12 | } 13 | \value{ 14 | filtered clinical info 15 | } 16 | \description{ 17 | Check Event and Time-to-event; remove NAs and time-to-event <=0 18 | } 19 | \examples{ 20 | \dontrun{ 21 | data(SKCM06info) 22 | dim(SKCM06info) 23 | info <- TimiCheckEvent(SKCM06info) 24 | dim(info) 25 | } 26 | } 27 | \author{ 28 | Chenyang Skylar Li 29 | } 30 | -------------------------------------------------------------------------------- /man/TimiDotplot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Dotplot.R 3 | \name{TimiDotplot} 4 | \alias{TimiDotplot} 5 | \title{Dotplot} 6 | \usage{ 7 | TimiDotplot( 8 | resdata = NULL, 9 | select = 1:5, 10 | condition = "Adjust.P.Value", 11 | cutoff = 0.05 12 | ) 13 | } 14 | \arguments{ 15 | \item{resdata}{TimiGP enrichment result generated from TimiEnrich} 16 | 17 | \item{select}{a numeric vector of selected cell interactions according to "Index" column in resdata. 18 | Default selection is top 5 enrichment.} 19 | 20 | \item{condition}{A value in one of 21 | c("P.Value","Adjust.P.Value","Permutation.FDR"), 22 | which is the column name of resdata and will be represented by color for the dot plot. 23 | The default value is the "Adjust.P.Value".} 24 | 25 | \item{cutoff}{The maximum value for the color bar. 26 | The default value is 0.05, which is used for the default condition "Adjust.P.Value". 27 | For other conditions, 0.01 is recommended for "P.Value", 28 | and 0.2 is recommended for "Permutation.FDR".} 29 | } 30 | \value{ 31 | Enrichment dotpot 32 | } 33 | \description{ 34 | A dotplot shows the results of selected cell interaction enrichment. 35 | The x-axis shows selected cell interactions. The y-axis shows Enrichment Ratio. 36 | The color of dots represents FDR. 37 | The size of dots represents the number of marker pairs 38 | shared by query pairs and annotation pairs. 39 | } 40 | \examples{ 41 | \dontrun{ 42 | data("Bindea2013c_enrich") 43 | res <- Bindea2013c_enrich 44 | p1<-TimiDotplot(res) 45 | p1 46 | p2<-TimiDotplot(res,select = c(1:10)) 47 | p2 48 | 49 | } 50 | } 51 | \author{ 52 | Chenyang Skylar Li 53 | } 54 | -------------------------------------------------------------------------------- /man/TimiEnrich.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Enrich.R 3 | \name{TimiEnrich} 4 | \alias{TimiEnrich} 5 | \title{Enrichment Analysis} 6 | \usage{ 7 | TimiEnrich( 8 | gene = NULL, 9 | background = NULL, 10 | geneset = NULL, 11 | p.adj = "BH", 12 | core = 1, 13 | pair = TRUE 14 | ) 15 | } 16 | \arguments{ 17 | \item{gene}{a vector of gene symbol} 18 | 19 | \item{background}{background genes or pairs} 20 | 21 | \item{geneset}{a data frame, column 1 shows cell (pair), 22 | column 2 shows gene (pair)} 23 | 24 | \item{p.adj}{p.adjust.methods. 25 | One of "holm", "hochberg", "hommel", "bonferroni", 26 | "BH", "BY", "fdr", "none". The default is "BH".} 27 | 28 | \item{core}{a numeric value shows the number of cores for parallel execution. 29 | The default value is 1.} 30 | 31 | \item{pair}{a logical value. If TRUE (default), 32 | perform enrichment analysis in cell pair. 33 | If using the function for general cell type enrichment analysis, 34 | please choose FALSE.} 35 | } 36 | \value{ 37 | A dataframe of enrichment results including cell-cell interactions 38 | } 39 | \description{ 40 | It statistically determines the inter-interactions 41 | by performing over-representation (enrichment analysis) 42 | } 43 | \examples{ 44 | \dontrun{ 45 | # Generate cell interaction Annotation: TimiCellPair 46 | data(CellType_Bindea2013_cancer) 47 | geneset <- CellType_Bindea2013_cancer 48 | cell_pair <- TimiCellPair(geneset = geneset,core = 20) 49 | # Select marker pairs A_B=1 associated with good prognosis 50 | data(Bindea2013c_COX_MP_SKCM06) 51 | cox_res <- Bindea2013c_COX_MP_SKCM06 52 | GP <- rownames(cox_res)[which(cox_res$QV<0.05)] 53 | # generate background: TimiBG 54 | background <- TimiBG(marker.pair = row.names(cox_res)) 55 | # Enrichment Analysis: TimiEnrich 56 | res <- TimiEnrich(gene = GP, background = background, 57 | geneset = cell_pair, p.adj = "BH",core=2) 58 | 59 | } 60 | } 61 | \author{ 62 | Chenyang Skylar Li 63 | } 64 | -------------------------------------------------------------------------------- /man/TimiFS.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Favorability.R 3 | \name{TimiFS} 4 | \alias{TimiFS} 5 | \title{Calculate Favorability Score of cell types} 6 | \usage{ 7 | TimiFS(resdata = NULL, condition = "Adjust.P.Value", cutoff = 0.05) 8 | } 9 | \arguments{ 10 | \item{resdata}{TimiGP enrichment result generated from TimiEnrich} 11 | 12 | \item{condition}{A value in one of 13 | c("P.Value","Adjust.P.Value","Permutation.FDR"), 14 | which is the column name of resdata. 15 | The default value is the "Adjust.P.Value".} 16 | 17 | \item{cutoff}{A cutoff of condition used to filter cell interactions. 18 | The default cutoff is 0.05.} 19 | } 20 | \value{ 21 | A matrix of Favorability Score 22 | which includes favorable score and unfavorable score. 23 | Difference = Favorable.Score - Unfavorable.Score. 24 | If Difference greater than 0, the cell type is classified as F(avorable) cell. 25 | If Difference is negative, the cell type is classified as F(avorable) cell. 26 | } 27 | \description{ 28 | It calculates the favorability score of each cell type 29 | based on TimiGP cell interaction network. 30 | The favorability score includes favorable score and unfavorable score. 31 | Favorable score: out-degree of the cell/sum of out-degree of all cell*100. 32 | Unfavorable score: in-degree of the cell/sum of in-degree of all cell*100. 33 | } 34 | \examples{ 35 | \dontrun{ 36 | data("Bindea2013c_enrich") 37 | res <- Bindea2013c_enrich 38 | score <- TimiFS(res, cutoff = 0.05) 39 | head(score) 40 | } 41 | } 42 | \author{ 43 | Chenyang Skylar Li 44 | } 45 | -------------------------------------------------------------------------------- /man/TimiFSBar.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Favorability.R 3 | \name{TimiFSBar} 4 | \alias{TimiFSBar} 5 | \title{Visualization of favorability score} 6 | \usage{ 7 | TimiFSBar(score = NULL, select = NULL) 8 | } 9 | \arguments{ 10 | \item{score}{Favorability score calculated from TimiFS} 11 | 12 | \item{select}{A numeric vector of selected cell interactions according to "Index" column in resdata. 13 | Default selection is all cell type.} 14 | } 15 | \value{ 16 | A barplot of Favorability Score 17 | } 18 | \description{ 19 | It generate a bar plot of the favorability score of cell type 20 | to evaluate its favorable(orange,positive) or unfavorable(Blue,negative) role in prognosis. 21 | } 22 | \examples{ 23 | \dontrun{ 24 | data("Bindea2013c_enrich") 25 | res <- Bindea2013c_enrich 26 | score <- TimiFS(res) 27 | head(score) 28 | p <- TimiFSBar(score) 29 | p 30 | } 31 | } 32 | \author{ 33 | Chenyang Skylar Li 34 | } 35 | -------------------------------------------------------------------------------- /man/TimiFisher.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Fisher.R 3 | \name{TimiFisher} 4 | \alias{TimiFisher} 5 | \title{Find marker pairs associated with response to therapy} 6 | \usage{ 7 | TimiFisher(mps = NULL, info = NULL, p.adj = "BH", parallel = FALSE, core = 1) 8 | } 9 | \arguments{ 10 | \item{mps}{a matrix of Marker Pair Score} 11 | 12 | \item{info}{a data.frame in which the 1st column contains 13 | two groups on response to therapy, "Responder == 1" & "Non-Responder == 0" 14 | and row name is patient ID.} 15 | 16 | \item{p.adj}{p.adjust.methods. 17 | One of "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none" 18 | The default value is "BH".} 19 | 20 | \item{parallel}{a logical value. If TRUE, enable parallel computing. 21 | The default value if FALSE} 22 | 23 | \item{core}{a numeric value shows the number of cores for parallel execution. 24 | The default value is 1.} 25 | } 26 | \value{ 27 | Result of fisher test 28 | (Rowname: Marker Pair,PV: P-Value,QV: Adjust P-value). 29 | } 30 | \description{ 31 | Perform fisher test (two sided) to look for marker pair associated with response to therapy. 32 | } 33 | \examples{ 34 | \dontrun{ 35 | # See example07 for more details 36 | # Load the example data 37 | data(TNBCaPD1info) 38 | data(TNBCaPD1rna) 39 | # Load the example cell type annotation 40 | data("CellType_TNBC_aPDL1") 41 | geneset <- CellType_TNBC_aPDL1 42 | marker <- unique(geneset$Gene) 43 | # Preprocess 44 | info <- TNBCaPD1info 45 | rna <- TimiPrePropress(marker = marker, cohort = rownames(info), 46 | log = F, GMNorm = T, rna = TNBCaPD1rna) 47 | # Generate marker pair score 48 | mps <- TimiGenePair(rna) 49 | # Use the function TimiFisher 50 | res <- TimiFisher(mps = mps,info = info,p.adj = "BH") 51 | # Assign results 52 | mps <- res$mps 53 | fisher_res <- res$fisher_res 54 | } 55 | } 56 | \author{ 57 | Chenyang Skylar Li 58 | } 59 | -------------------------------------------------------------------------------- /man/TimiGeneChord.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ChordDiagram.R 3 | \name{TimiGeneChord} 4 | \alias{TimiGeneChord} 5 | \title{Chord diagram of Gene Interaction} 6 | \usage{ 7 | TimiGeneChord(resdata = NULL, select = 1, color = NULL) 8 | } 9 | \arguments{ 10 | \item{resdata}{TimiGP enrichment result generated from TimiEnrich} 11 | 12 | \item{select}{A numeric value of selected cell interactions according to "Index" column. 13 | Default selection is the top 1 cell interaction.} 14 | 15 | \item{color}{A vector of self-defined marker colors, 16 | whose names are the enriched markers 17 | (not pair,you need to split the genes in Shared.IMGP column) 18 | in selected cell interaction.} 19 | } 20 | \value{ 21 | Chord diagram of Gene Interaction 22 | } 23 | \description{ 24 | Chord diagram reveals the gene interactions of a selected cell interaction. 25 | The arrow points from enriched marker F of favorable cell type A 26 | to enriched marker U of unfavorable cell type B, 27 | which denotes that 28 | the expression of F greater than that of U is associated with a good prognosis. 29 | } 30 | \examples{ 31 | \dontrun{ 32 | data("Bindea2013c_enrich") 33 | res <- Bindea2013c_enrich 34 | TimiGeneChord(resdata = res) 35 | TimiGeneChord(resdata = res,select = 2) 36 | 37 | } 38 | } 39 | \author{ 40 | Chenyang Skylar Li 41 | } 42 | -------------------------------------------------------------------------------- /man/TimiGeneNetwork.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Network.R 3 | \name{TimiGeneNetwork} 4 | \alias{TimiGeneNetwork} 5 | \title{Generate gene network files for Cytoscape} 6 | \usage{ 7 | TimiGeneNetwork( 8 | resdata = NULL, 9 | select = NULL, 10 | dataset = NULL, 11 | geneset = NULL, 12 | condition = "QV", 13 | cutoff = 0.05, 14 | export = TRUE, 15 | path = NULL 16 | ) 17 | } 18 | \arguments{ 19 | \item{resdata}{TimiGP cox result generated from TimiCOX} 20 | 21 | \item{select}{A character vector of selected gene pairs according to rownames in resdata. 22 | Default selection is all cell-cell interactions(adjusted p value < 0.05).} 23 | 24 | \item{dataset}{A value in one of 25 | c("Bindea2013_Cancer","Immune3", 26 | "Newman2015", 27 | "Tirosh2016","Zheng2021","Other") 28 | The first four options include default group and color settings. 29 | If you use other dataset or want to change group and colors, 30 | please choose "Other".} 31 | 32 | \item{geneset}{A data.frame of cell markers, 33 | in which the 1st column is cell type, 34 | the 2nd column is the marker gene 35 | and the 3rd column is the name of the dataset(optional)} 36 | 37 | \item{condition}{A value in one of 38 | "PV" (P.Value) and "QV" (Adjust.P.Value), 39 | which is the column name of resdata. 40 | The default value is the "QV".} 41 | 42 | \item{cutoff}{A cutoff of condition used to filter gene interactions. 43 | The default cutoff is 0.05.} 44 | 45 | \item{export}{A logical value. If TRUE, it will generate network files 46 | for Cytoscape analysis. The default value is TRUE.} 47 | 48 | \item{path}{A directory to export the network files when "export = TRUE".} 49 | } 50 | \value{ 51 | A list of network required files(network,node,edge) 52 | } 53 | \description{ 54 | It generates three files that can be used to build network in Cytoscape: 55 | 1. network files: simple interaction file (gene_network.sif); 56 | 2. node attributes (gene_node.txt); 57 | 3. edge attributes (gene_edge.txt). 58 | The function also returns a list of above files that can be modified in R. 59 | } 60 | \examples{ 61 | \dontrun{ 62 | data(Bindea2013c_COX_MP_SKCM06) 63 | cox_res <- Bindea2013c_COX_MP_SKCM06 64 | NET <- TimiGeneNetwork(resdata = cox_res,dataset = "Bindea2013_Cancer",export=T,path="./") 65 | } 66 | } 67 | \author{ 68 | Chenyang Skylar Li 69 | } 70 | -------------------------------------------------------------------------------- /man/TimiGenePair.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Pairwise.R 3 | \name{TimiGenePair} 4 | \alias{TimiGenePair} 5 | \title{Capture logical/continuous relation between marker pairs} 6 | \usage{ 7 | TimiGenePair(rna = NULL, both = FALSE, cont = FALSE) 8 | } 9 | \arguments{ 10 | \item{rna}{a data.frame of preprocessed transcriptomic profile} 11 | 12 | \item{both}{a logical value. 13 | The default is FALSE that only keep A_B pairs 14 | If TRUE, keep both A_B and B_A pairs, this is only for ssTimiGP.} 15 | 16 | \item{cont}{a logical value. If TRUE, capture the continuous relation. 17 | The default is FALSE} 18 | } 19 | \value{ 20 | a matrix of Marker Pair Score 21 | } 22 | \description{ 23 | Default: Capture logical relation of any two marker pairs, 24 | and generate a matrix of Marker Pair Score: 25 | 1 or TRUE = the expression of gene A > that of gene B, 26 | 0 or FALSE = the expression of gene A < that of gene B. 27 | \cr 28 | Optional: Capture continuous relation of any two marker pairs, 29 | and generate a matrix of Marker Pair Score: 30 | the expression of gene A - that of gene B, 31 | } 32 | \examples{ 33 | \dontrun{ 34 | data("SKCM06info") 35 | data("SKCM06rna") 36 | data("Immune_Marker_n1293") 37 | dim(SKCM06info) 38 | info <- TimiCheckEvent(SKCM06info) 39 | dim(info) 40 | dim(SKCM06rna) 41 | rna <- TimiPrePropress(gene = Immune_Marker_n1293,rna = SKCM06rna,cohort = rownames(info)) 42 | # TimiGenePair 43 | mps <- TimiGenePair(rna) 44 | dim(mps) 45 | } 46 | } 47 | \author{ 48 | Chenyang Skylar Li 49 | } 50 | -------------------------------------------------------------------------------- /man/TimiPermFDR.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Permutation.R 3 | \name{TimiPermFDR} 4 | \alias{TimiPermFDR} 5 | \title{Permutation of marker genes to control FDR} 6 | \usage{ 7 | TimiPermFDR( 8 | resdata = NULL, 9 | geneset = NULL, 10 | gene = NULL, 11 | background = NULL, 12 | niter = 100, 13 | core = 1 14 | ) 15 | } 16 | \arguments{ 17 | \item{resdata}{TimiGP enrichment result generated from TimiEnrich} 18 | 19 | \item{geneset}{a data.frame of cell markers used in TimiCellPair, 20 | in which the 1st column is cell type, 21 | the 2nd column is the marker gene 22 | and the 3rd column is the name of the dataset (optional)} 23 | 24 | \item{gene}{a vector of gene symbol used in TimiEnrich} 25 | 26 | \item{background}{background genes or pairs used in TimiEnrich} 27 | 28 | \item{niter}{A numeric value used to determine the number of permutation. 29 | The default cutoff is 100.} 30 | 31 | \item{core}{a numeric value shows the number of cores 32 | for parallel execution. The default value is 1.} 33 | } 34 | \value{ 35 | A new column "Permutation.FDR" is appended to 36 | dataframe of cell-cell interactions generated from TimiEnrich 37 | } 38 | \description{ 39 | It conservatively permutates marker gene sets for all cell types 40 | by shuffling their marker genes while preserving the sizes of their sets. 41 | This permutation breaks the underlying association 42 | between the genes and the cell types, 43 | which enables the examination of cell-type marker quality 44 | and the control of false positives in identifying cell interactions. 45 | It exports the FDR (Q value) of each interaction. 46 | } 47 | \examples{ 48 | \dontrun{ 49 | data("Bindea2013c_enrich") 50 | res <- Bindea2013c_enrich 51 | res <- TimiPermFDR(resdata = res, geneset = geneset, gene = GP, 52 | background = background, niter = 100, core = 20) 53 | head(score) 54 | } 55 | } 56 | \author{ 57 | Chenyang Skylar Li 58 | } 59 | -------------------------------------------------------------------------------- /man/TimiPrePropress.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Preprocess.R 3 | \name{TimiPrePropress} 4 | \alias{TimiPrePropress} 5 | \title{Preprocess Transctiptomic profile} 6 | \usage{ 7 | TimiPrePropress(marker, rna = NULL, cohort, log = TRUE, GMNorm = TRUE) 8 | } 9 | \arguments{ 10 | \item{marker}{a vector of marker gene list.} 11 | 12 | \item{rna}{a data.frame of transcriptomic profile, 13 | in which row names are genes and colnames are individuals.} 14 | 15 | \item{cohort}{a vector of selected individuals.} 16 | 17 | \item{log}{logical value: 18 | if TRUE, log transformation will be performed; The default is TRUE.} 19 | 20 | \item{GMNorm}{logical value: 21 | if TRUE, gene wise median normalization will be performed; The default is TRUE.} 22 | } 23 | \value{ 24 | Preprocessed transctiptomic profile 25 | } 26 | \description{ 27 | Given the transcriptomic profile, marker gene list, clinical information, 28 | this function will return the marker gene expression in selected cohort, 29 | after log transformation and gene wise median normalization 30 | } 31 | \examples{ 32 | \dontrun{ 33 | data("SKCM06info") 34 | data("SKCM06rna") 35 | data("Immune_Marker_n1293") 36 | dim(SKCM06info) 37 | info <- TimiCheckEvent(SKCM06info) 38 | dim(info) 39 | dim(SKCM06rna) 40 | rna <- TimiPrePropress(gene = Immune_Marker_n1326,rna = SKCM06rna,cohort = rownames(info), log = T,GMNorm = T) 41 | dim(rna) 42 | } 43 | } 44 | \author{ 45 | Chenyang Skylar Li 46 | } 47 | --------------------------------------------------------------------------------