├── .Rbuildignore ├── .gitignore ├── CITATION.cff ├── DESCRIPTION ├── LICENSE ├── NAMESPACE ├── R ├── CreateDEGContainer.R ├── MSigDBSummary.R ├── Visualization_DEG.R ├── Visualization_DEGvolcano.R ├── Visualization_check.R ├── Visualization_enrichBar.R ├── Visualization_enrichCirclize.R ├── Visualization_gse.R ├── allClass.R ├── allGeneric.R ├── allMethods.R ├── createOB.R ├── createParam.R ├── degGroup.R ├── degResolve.R ├── degResolveArray.R ├── degSummary.R ├── gseResolve.R ├── gseSummary.R ├── hyperResolve.R ├── hyperSummary.R ├── msigdbResolve.R ├── runALL.R ├── runCheck.R ├── runDEG.R ├── runGSEA.R ├── runHyper.R ├── runMSigDB.R ├── utils-go.R ├── utils-pipe.R └── utils.R ├── README.md ├── RNAseqStat2.Rproj ├── dev ├── Msigdb.R ├── RNAseqStat2.xmind ├── TestWorkflowArray.R ├── Testworkflow.R ├── bingxing.R ├── ci.R ├── deg_data.Rdata ├── git.R ├── license.R ├── load.R ├── minimal_step.R ├── readme.R ├── test_GO.R ├── theme.R └── usepackages.R └── man ├── Create_DEGContainer.Rd ├── Create_MSigDB.Rd ├── Create_dataInfo.Rd ├── Create_gseParam.Rd ├── Create_hyperParam.Rd ├── Create_msigdbGSEAparam.Rd ├── Create_msigdbHyperParam.Rd ├── Create_msigdbParam.Rd ├── Create_treatInfo.Rd ├── DEGContainer.Rd ├── DEGtopHeatmap.Rd ├── DEGvenn.Rd ├── DESeq2_resolve.Rd ├── FC_Identify.Rd ├── GSEAbar.Rd ├── GSEAplot.Rd ├── HKG_check.Rd ├── MSigDB.Rd ├── MSigDBSummary.Rd ├── PointVolcano.Rd ├── ac_.Rd ├── box_check.Rd ├── cleanSYMBOL.Rd ├── commonGroup.Rd ├── compareEnrichCircle.Rd ├── cor500_check.Rd ├── corall_check.Rd ├── cutFC_Verify.Rd ├── cutMuch.Rd ├── dataDEG.Rd ├── dataInfo.Rd ├── degGroup.Rd ├── degResolve.Rd ├── degResolveArray.Rd ├── degResults.Rd ├── degSummary.Rd ├── deg_here.Rd ├── density_check.Rd ├── edgeR_resolve.Rd ├── eggnogG2T.Rd ├── enrichBar.Rd ├── enrichGO2.Rd ├── exprBox.Rd ├── exprCorHeatmap.Rd ├── exprHKGheatmap.Rd ├── exprPCA.Rd ├── exprRidges.Rd ├── exprTopHeatmap.Rd ├── geom_volcano_point.Rd ├── geom_volcano_text.Rd ├── get_breaks.Rd ├── groupCir.Rd ├── gseGO2.Rd ├── gseMSigDB.Rd ├── gseResolve.Rd ├── gseSummary.Rd ├── gsvaResolve.Rd ├── heatCir.Rd ├── heatLegend.Rd ├── highlightGroup.Rd ├── hyperBar.Rd ├── hyperMSigDB.Rd ├── hyperMSigDB_Resolve.Rd ├── hyperResolve.Rd ├── hyperSummary.Rd ├── hyper_GS.Rd ├── idLegend.Rd ├── limma_resolve.Rd ├── limma_resolveArray.Rd ├── linkCir.Rd ├── modelEnrich.Rd ├── msigdbGet.Rd ├── newDEGContainer.Rd ├── paletteCir.Rd ├── pca_check.Rd ├── pipe.Rd ├── pvalue_Identify.Rd ├── rectCir.Rd ├── rectCirDiscrete.Rd ├── runALL.Rd ├── runCheck.Rd ├── runDEG.Rd ├── runGSEA.Rd ├── runHyper.Rd ├── runMSigDB.Rd ├── textBarData.Rd ├── theme_volcano.Rd ├── toSYMBOL.Rd ├── top1000_check.Rd ├── topGene.Rd ├── volcano_nudge_x_down.Rd └── volcano_nudge_x_up.Rd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^data-raw$ 4 | ^dev$ 5 | ^codecov\.yml$ 6 | ^README\.Rmd$ 7 | ^\.github$ 8 | ^\.git$ 9 | ^LICENSE\.md$ 10 | ^_pkgdown\.yml$ 11 | ^docs$ 12 | ^pkgdown$ 13 | ^doc$ 14 | ^Meta$ 15 | ^output_test.* 16 | ^CITATION.cff 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .Rdata 4 | .httr-oauth 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | # This CITATION.cff file was generated with cffinit. 2 | # Visit https://bit.ly/cffinit to generate yours today! 3 | 4 | cff-version: 1.2.0 5 | title: 'RNAseqStat2: A Pipeline to Process RNAseq Data' 6 | message: >- 7 | If you use this software, please cite it using the 8 | metadata from this file. 9 | type: software 10 | authors: 11 | - family-names: Xia 12 | email: xiayh17@gmail.com 13 | given-names: Yonghe 14 | - family-names: Zeng 15 | given-names: Jianming 16 | email: jmzeng1314@163.com 17 | identifiers: 18 | - type: url 19 | value: 'https://github.com/xiayh17/RNAseqStat2' 20 | description: The URL of GitHub repository of the software 21 | repository-code: 'https://github.com/xiayh17/RNAseqStat2' 22 | repository: 'https://github.com/xiayh17/RNAseqStat2' 23 | commit: dc0bde0e443b8e2fe8d8d95eea2c9e7f731572f9 24 | version: 0.1.0.9993 25 | date-released: '2022-05-20' 26 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: RNAseqStat2 2 | Type: Package 3 | Title: A Pipeline to Process RNAseq Data 4 | Version: 0.1.0.9993 5 | Authors@R: c( 6 | person("Jianming","Zeng", 7 | email = "jmzeng1314@163.com", 8 | role = c("aut", "ctb")), 9 | person(given = "Yonghe", 10 | family = "Xia", 11 | role = c("aut", "ctb", "cre"), 12 | email = "xiayh17@gmail.com"), 13 | person("Biotrainee group",role = c("cph","fnd")) 14 | ) 15 | Maintainer: Yonghe Xia 16 | Description: More about what it does (maybe more than one line) 17 | Use four spaces when indenting paragraphs within the Description. 18 | License: MIT + file LICENSE 19 | Encoding: UTF-8 20 | LazyData: true 21 | Depends: 22 | R (>= 4.1.0) 23 | RoxygenNote: 7.2.3 24 | BugReports: https://github.com/xiayh17/RNAseqStat2/issues 25 | Suggests: 26 | testthat (>= 3.0.0), 27 | covr, 28 | knitr, 29 | rmarkdown, 30 | pdftools, 31 | png 32 | Imports: 33 | fs, 34 | edgeR, 35 | glue, 36 | usethis, 37 | DESeq2, 38 | SummarizedExperiment, 39 | FactoMineR, 40 | factoextra, 41 | ggplot2, 42 | RColorBrewer, 43 | pheatmap, 44 | data.table, 45 | utils, 46 | ggrepel, 47 | stats, 48 | DOSE, 49 | clusterProfiler, 50 | kit, 51 | limma, 52 | methods, 53 | qvalue, 54 | grid, 55 | dplyr, 56 | forcats, 57 | ggnewscale, 58 | stringr, 59 | enrichplot, 60 | plyr, 61 | GSEABase, 62 | GSVA, 63 | msigdbr, 64 | AnnoProbe, 65 | ggtext, 66 | ggdist, 67 | ggridges, 68 | tibble, 69 | Cairo, 70 | ggfun, 71 | ggfittext, 72 | circlize, 73 | ComplexHeatmap, 74 | MetBrewer, 75 | textshape, 76 | reshape2, 77 | cowplot, 78 | VennDiagram, 79 | aplot (>= 0.0.7) 80 | biocViews: DataImport, Microarray, OneChannel, SAGE, Software, TwoChannel 81 | Config/testthat/edition: 3 82 | VignetteBuilder: knitr 83 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2021 2 | COPYRIGHT HOLDER: RNAseqStat authors 3 | -------------------------------------------------------------------------------- /R/CreateDEGContainer.R: -------------------------------------------------------------------------------- 1 | #' Create \code{DEGContainer} 2 | #' 3 | #' Begin in DEGContainer. 4 | #' 5 | #' @param species species for your data. 6 | #' @param dataType kind of expresses value matrix. `Counts` (Integer) or `Array` (Decimal). 7 | #' @param idType kind of gene id. `ENSEMBL` or `SYMBOL`, If `ENSEMBL`,\code{species} supposed be one of (`Human`, `Mouse` and `Rat`), it will be automatically converted to `SYMBOL`. 8 | #' @param expMatrix expresses value matrix. Should be a data.frame row named by gene ID and column named by Sample 9 | #' @param groupInfo a Character Vectors ordered by samples in matrix. 10 | #' @param caseGroup a Character names of case group. 11 | #' @param filterMethod a function used to filter expresses value matrix. Or disable filter by set as `NULL`. 12 | #' @param msi_species one of \code{\link[msigdbr]{msigdbr_species}} 13 | #' @param msi_category MSigDB collection abbreviation, such as H or C1. 14 | #' @param OrgDb Select an OrgDb. 15 | #' @param organism Select an organism. 16 | #' @param GOTERM2GENE custom enrich data of GO. 17 | #' @param GOTERM2NAME custom enrich data of GO. 18 | #' @param KEGGTERM2GENE custom enrich data of GSE. 19 | #' @param KEGGTERM2NAME custom enrich data of GSE. 20 | #' 21 | #' @details `Human`, `Mouse` and `Rat` is full supported. For other species, more setting is needed. \cr 22 | #' If data can't provided, related steps in workflow will ignore. \cr 23 | #' OrgDb can be find from here \link{https://bioconductor.org/packages/release/BiocViews.html#___OrgDb} \cr 24 | #' organism can be find from here \link{https://www.genome.jp/kegg/catalog/org_list.html} \cr 25 | #' msi_species can be get from \code{\link[msigdbr]{msigdbr_species}} \cr 26 | #' 27 | #' @importFrom usethis ui_info ui_done ui_code ui_oops ui_stop 28 | #' 29 | #' @return a \code{DEGContainer} object 30 | #' @export 31 | #' 32 | #' @examples 33 | #' Create_DEGContainer(expMatrix = counts_input,groupInfo = c("C","C","C","T","T","T"),caseGroup = "T") 34 | Create_DEGContainer <- function(species = "Human", 35 | dataType = "Counts", 36 | idType = "SYMBOL", 37 | expMatrix, 38 | groupInfo, 39 | caseGroup, 40 | filterMethod = "rowSums(expMatrix > 0) >= ncol(expMatrix)/2", 41 | msi_species = NULL, msi_category = "H", 42 | OrgDb = NULL, organism = NULL, 43 | GOTERM2GENE = NULL, GOTERM2NAME = NA, 44 | KEGGTERM2GENE = NULL, KEGGTERM2NAME = NA){ 45 | 46 | expMatrix <- as.data.frame(expMatrix) 47 | 48 | ## convert ids 49 | if (idType == "ENSEMBL"&presetSpecies(species)) { 50 | 51 | expMatrix <- suppressWarnings(toSYMBOL(row_counts = expMatrix,species = species)) 52 | idType = "SYMBOL" 53 | ui_done("ENSEMBL named expression matrix renamed by SYMBOL") 54 | } else if (idType != "SYMBOL"&!presetSpecies(species)) { 55 | ui_stop("{ui_code('idType')} should be 'SYMBOL'") 56 | } 57 | 58 | ## check filter 59 | if(is.null(filterMethod)){ 60 | 61 | ui_info("Nothing filtered in your data.") 62 | matrixFiltered = expMatrix 63 | 64 | } else { 65 | 66 | keep_feature <- eval(parse(text = filterMethod)) 67 | matrixFiltered <- as.data.frame(expMatrix[keep_feature,]) 68 | left = nrow(matrixFiltered) 69 | 70 | if (left == 0) { 71 | 72 | matrixFiltered = NULL 73 | ui_stop("Your {ui_code('filterMethod')} have some problem OR too Strict. 74 | It Should be something like {ui_code('rowSums(expMatrix > 0) >= ncol(expMatrix)/2')} in a character.") 75 | 76 | } else { 77 | 78 | ui_done("Your data have filtered by {ui_code(filterMethod)}") 79 | ui_info("{left} Keeped, {nrow(expMatrix) - left} removed. ") 80 | 81 | } 82 | } 83 | 84 | ## Create basic data info 85 | dataInfo <- Create_dataInfo( 86 | species = species, 87 | dataType = dataType, 88 | idType = idType, 89 | expMatrix = expMatrix, 90 | groupInfo = groupInfo, 91 | caseGroup = caseGroup, 92 | filterMethod = filterMethod, 93 | matrixFiltered = matrixFiltered 94 | ) 95 | 96 | ## Create zero for DEG 97 | degResults <- suppressWarnings(Create_degResults( 98 | vsData = Create_vsData(), 99 | treatInfo = Create_treatInfo() 100 | )) 101 | 102 | ## Create zero for enrich 103 | if(presetSpecies(species)&is.null(GOTERM2GENE)&is.null(KEGGTERM2GENE)) { 104 | 105 | OrgDb = switch (species, 106 | 'Human' = "org.Hs.eg.db", 107 | 'Mouse' = "org.Mm.eg.db", 108 | "Rat" = "org.Rn.eg.db" 109 | ) 110 | 111 | organism = switch (species, 112 | 'Human' = "hsa", 113 | 'Mouse' = "mmu", 114 | 'Rat' = "rno" 115 | ) 116 | 117 | msi_species <- switch (species, 118 | 'Human' = "Homo sapiens", 119 | 'Mouse' = "Mus musculus", 120 | 'Rat' = "Rattus norvegicus" 121 | ) 122 | 123 | hyperParam = Create_hyperParam(goParam = list(OrgDb = OrgDb), 124 | keggParam = list(organism = organism)) 125 | gseParam = Create_gseParam(goParam = list(OrgDb = OrgDb), 126 | keggParam = list(organism = organism)) 127 | 128 | msigdbParam = Create_msigdbParam(msigdbParam = list(species = msi_species,category = msi_category)) 129 | 130 | shotSpecies(species) 131 | 132 | } else { 133 | 134 | if(!is.null(GOTERM2GENE)) { 135 | GOcustom = TRUE 136 | skipGO = FALSE 137 | goParam = list(TERM2GENE = GOTERM2GENE, TERM2NAME = GOTERM2NAME) 138 | } else if (!is.null(OrgDb)) { 139 | GOcustom = FALSE 140 | skipGO = FALSE 141 | goParam = list(OrgDb = OrgDb) 142 | } else { 143 | GOcustom = FALSE 144 | goParam = NULL 145 | skipGO = TRUE 146 | ui_oops("hyperGO and gseGO step will skip for lack data") 147 | } 148 | 149 | if(!is.null(KEGGTERM2GENE)) { 150 | KEGGcustom = TRUE 151 | skipKEGG = FALSE 152 | keggParam = list(TERM2GENE = KEGGTERM2GENE, TERM2NAME = KEGGTERM2NAME) 153 | } else if (!is.null(organism)) { 154 | KEGGcustom = FALSE 155 | skipKEGG = FALSE 156 | keggParam = list(organism = organism) 157 | } else { 158 | KEGGcustom = FALSE 159 | keggParam = NULL 160 | skipKEGG = TRUE 161 | ui_oops("hyperKEGG and gseKEGG step will skip for lack data") 162 | } 163 | 164 | if(!is.null(msi_species)) { 165 | msigdbParam = Create_msigdbParam(msigdbParam = list(species = msi_species,category = msi_category)) 166 | skipMSigDB = FALSE 167 | } else { 168 | msigdbParam = NULL 169 | skipMSigDB = TRUE 170 | ui_oops("MSigDB step will skip for lack data") 171 | } 172 | 173 | if(all(is.null(GOTERM2GENE),is.null(OrgDb),is.null(KEGGTERM2GENE),is.null(organism),is.null(msi_species))){ 174 | 175 | shotSpecies(species) 176 | 177 | } 178 | 179 | hyperParam = Create_hyperParam(goParam = goParam,keggParam = keggParam, 180 | customGO = GOcustom,customKEGG = KEGGcustom,skipGO = skipGO,skipKEGG = skipKEGG) 181 | 182 | gseParam = Create_gseParam(goParam = goParam,keggParam = keggParam, 183 | customGO = GOcustom,customKEGG = KEGGcustom,skipGO = skipGO,skipKEGG = skipKEGG) 184 | 185 | msigdbParam = Create_msigdbParam(msigdbParam = list(species = msi_species,category = msi_category),skipMSigDB = skipMSigDB) 186 | 187 | } 188 | 189 | hyperResults <- suppressWarnings(Create_hyperResults(hyperParam=hyperParam)) 190 | gseResults <- suppressWarnings(Create_gseResults(gseParam=gseParam)) 191 | 192 | MSigDB = suppressWarnings(Create_MSigDB(msigdbParam = msigdbParam, 193 | msigdbGSEAparam = Create_msigdbGSEAparam(), 194 | msigdbHyperParam = Create_msigdbHyperParam())) 195 | 196 | newDEGContainer(dataInfo = dataInfo, 197 | degResults = degResults, 198 | hyperResults = hyperResults, 199 | gseResults = gseResults, 200 | MSigDB = MSigDB) 201 | 202 | } 203 | 204 | # https://bioconductor.org/packages/release/BiocViews.html#___OrgDb 205 | # https://www.genome.jp/kegg/catalog/org_list.html 206 | shotSpecies <- function(species) { 207 | if(presetSpecies(species)) { 208 | usethis::ui_done("Your species will be resolved all automaticly") 209 | } else { 210 | usethis::ui_oops("The species {ui_value(species)} is out one of preset {ui_value('Human,Mouse,Rat')}"); 211 | usethis::ui_todo("We need you provide more parameters for your species."); 212 | usethis::ui_todo("{ui_code('OrgDb')} parameters should be set one of below page"); 213 | usethis::ui_todo("{ui_path('https://bioconductor.org/packages/release/BiocViews.html#___OrgDb')}"); 214 | usethis::ui_todo("{ui_code('organism')} parameters should be set one of below page"); 215 | usethis::ui_todo("{ui_path('https://www.genome.jp/kegg/catalog/org_list.html')}"); 216 | usethis::ui_todo("Or you can use custom species by {ui_code('GOTERM2GENE')} and {ui_code('GOTERM2GENE')} 217 | Here is a help page to more details. {ui_path('www.xiayh17.com')}"); 218 | } 219 | } 220 | 221 | presetSpecies <- function(species) { 222 | 223 | species %in% c("Human","Mouse","Rat") 224 | 225 | } 226 | -------------------------------------------------------------------------------- /R/MSigDBSummary.R: -------------------------------------------------------------------------------- 1 | #' Summary MSigDB modules results 2 | #' 3 | #' @param obj a DEGContainer 4 | #' @param dir a directory to store results 5 | #' @param prefix a prefix of file names in this step 6 | #' @param top top of hyper or gsea 7 | #' 8 | #' @return 9 | #' @export 10 | #' 11 | #' @examples 12 | #' MSigDBSummary(data_msigdb) 13 | MSigDBSummary <- function(obj, dir = ".", prefix = "5-runMSigDB",top =10) { 14 | 15 | ## plot 16 | ## gse ---- 17 | gse_list <- msigdbGSEAresult(obj) 18 | 19 | if(length(gse_list) != 0){ 20 | 21 | tmp <- lapply(msigdbParam(obj)[["category"]], function(j){ 22 | 23 | cat <- switch (j, 24 | "H" = "HALLMARK", 25 | "C1" = "positional", 26 | "C2" = "curated", 27 | "C3" = "regulatory_target", 28 | "C4" = "computational", 29 | "C5" = "ontology", 30 | "C6" = "oncogenic_signature", 31 | "C7" = "immunologic_signature", 32 | "C8" = "cell_type_signature" 33 | ) 34 | 35 | tmp <- lapply(seq_along(gse_list), function(i){ 36 | 37 | y = gse_list[[i]] 38 | x = y[[j]] 39 | dat = x@result 40 | 41 | res_name <- glue("{dir}/{prefix}_GSEA_{names(gse_list)[i]}_{j}.csv") 42 | write.csv(dat,file = res_name) 43 | ui_done(glue("{names(gse_list)[i]} {j} GSEA result in csv format is stored in {usethis::ui_path(res_name)}")) 44 | 45 | }) 46 | 47 | plot_list <- lapply(seq_along(gse_list), function(i){ 48 | 49 | y = gse_list[[i]] 50 | x = y[[j]] 51 | GSEAbar(x,top = top) + 52 | theme(legend.position="none") + 53 | ggtitle(names(gse_list)[i]) 54 | 55 | }) 56 | 57 | legend <- cowplot::get_legend( 58 | # create some space to the left of the legend 59 | plot_list[[1]] + ggplot2::theme(legend.position="right",legend.box.margin = ggplot2::margin(0, 0, 0, 12)) 60 | ) 61 | 62 | p <- cowplot::plot_grid(plotlist = plot_list,legend,ncol = 5, rel_widths = c(.4,3,3,3,3)) 63 | 64 | ggplot2::ggsave(p,filename = glue::glue("{dir}/{prefix}_GSEA_bar_{cat}.pdf"), width = 6400,height = 1200*(top*2/10),units = "px",limitsize = FALSE,device = cairo_pdf) 65 | 66 | 67 | tmp <- lapply(seq_along(gse_list), function(i){ 68 | 69 | y = gse_list[[i]] 70 | x = y[[j]] 71 | 72 | gseaplots_l <- GSEAplot(x,top =top) 73 | 74 | ## 保存gse富集趋势图到多页pdf 75 | mod <- names(gse_list)[i] 76 | down_plots_pdf <- glue("{dir}/{prefix}_GSEA_{mod}_{cat}_Down_gseplot.pdf") 77 | pdf(down_plots_pdf,height = 3,width = 4) 78 | invisible(lapply(gseaplots_l[["down_plots"]], print)) 79 | dev.off() 80 | ui_done(glue("Enrichplot of GSEA head {top} {mod} {cat} in Down ploted in {ui_path({down_plots_pdf})}")) 81 | 82 | up_plots_pdf <- glue("{dir}/{prefix}_GSEA_{mod}_{cat}_Up_gseplot.pdf") 83 | pdf(up_plots_pdf,height = 3,width = 4) 84 | invisible(lapply(gseaplots_l[["up_plots"]], print)) 85 | dev.off() 86 | ui_done(glue("Enrichplot of GSEA head {top} {mod} {cat} in Up ploted in {ui_path({up_plots_pdf})}")) 87 | 88 | }) 89 | 90 | 91 | }) 92 | 93 | } 94 | ## ---- 95 | 96 | ## hyper ---- 97 | hyper_list <- msigdbHyperResult(obj) 98 | 99 | index <- c(setdiff(label(obj),label_ns(obj)),"diff") 100 | 101 | if (length(hyper_list) != 0) { 102 | 103 | tmp <- lapply(index, function(i){ 104 | 105 | lapply(msigdbParam(obj)[["category"]], function(j){ 106 | 107 | cat <- switch (j, 108 | "H" = "HALLMARK", 109 | "C1" = "positional", 110 | "C2" = "curated", 111 | "C3" = "regulatory_target", 112 | "C4" = "computational", 113 | "C5" = "ontology", 114 | "C6" = "oncogenic_signature", 115 | "C7" = "immunologic_signature", 116 | "C8" = "cell_type_signature" 117 | ) 118 | 119 | plot_list <- lapply(seq_along(hyper_list), function(k){ 120 | 121 | x = hyper_list[[k]] 122 | set <- x[[j]] 123 | eob <- set[[i]] 124 | 125 | res_name <- glue("{dir}/{prefix}_Hyper_{names(hyper_list)[k]}_{j}_{i}.csv") 126 | write.csv(eob@result,file = res_name) 127 | ui_done(glue("{names(hyper_list)[k]} {j} {i} Hyper result in csv format is stored in {usethis::ui_path(res_name)}")) 128 | 129 | if(!is.null(eob)){ 130 | hyperBar(eob,top = top)+ theme(legend.position="none") + ggtitle(names(hyper_list)[j]) 131 | } 132 | 133 | }) 134 | 135 | legend <- cowplot::get_legend( 136 | # create some space to the left of the legend 137 | plot_list[[1]] + ggplot2::theme(legend.position="right",legend.box.margin = ggplot2::margin(0, 0, 0, 12)) 138 | ) 139 | 140 | p <- cowplot::plot_grid(plotlist = plot_list,legend,ncol = 5, rel_widths = c(.4,3,3,3,3)) 141 | 142 | plot_path = glue::glue("{dir}/{prefix}_Hyper_{j}_{i}.pdf") 143 | ggplot2::ggsave(p,filename = plot_path, width = 6400,height = 1200*(top*2/10),units = "px",limitsize = FALSE,device = cairo_pdf) 144 | 145 | ui_done(glue("{j} {i} Genes Hyper result is stored in {usethis::ui_path(plot_path)}")) 146 | 147 | }) 148 | 149 | }) 150 | 151 | } 152 | 153 | 154 | ## ---- 155 | 156 | ## gsva 157 | gsvares_list <- msigdbGSVAresult(obj)[["GSVA_matrix"]] 158 | invisible(lapply(seq_along(gsvares_list), function(x){ 159 | 160 | pdf_file = glue("{dir}/{prefix}_GSVA_{names(gsvares_list)[x]}.pdf") 161 | ac=data.frame(Groups=groupInfo(obj)) 162 | rownames(ac)=sampleNames(obj,filtered = T) 163 | pheatmap::pheatmap(gsvares_list[[x]], 164 | annotation_col = ac, 165 | filename = pdf_file) 166 | ui_done("{names(gsvares_list)[x]} GSVA heatmap is stored in {usethis::ui_path(pdf_file)}") 167 | 168 | csv_file = glue("{dir}/{prefix}_GSVA_{names(gsvares_list)[x]}_matrix.csv") 169 | write.csv(gsvares_list[[x]],file = csv_file) 170 | ui_done("{names(gsvares_list)[x]} GSVA matrix is stored in {usethis::ui_path(csv_file)}") 171 | 172 | })) 173 | 174 | gsvadiff_list <- msigdbGSVAresult(obj)[["GSVA_diff"]] 175 | invisible(lapply(seq_along(gsvadiff_list), function(x){ 176 | 177 | csv_file = glue("{dir}/{prefix}_GSVA_{names(gsvadiff_list)[x]}_limmaDEG.csv") 178 | write.csv(gsvadiff_list[[x]],file = csv_file) 179 | ui_done("{names(gsvadiff_list)[x]} GSVA analysis by limma is stored in {usethis::ui_path(csv_file)}") 180 | 181 | volcano_file = glue("{dir}/{prefix}_GSVA_{names(gsvadiff_list)[x]}_volcano.pdf") 182 | p <- PointVolcano(object = obj,which = "MSigDB",category = names(gsvadiff_list)[x],gene = 5,expend = c(0.4,0.4)) 183 | ggsave(p,filename = volcano_file, width = 1600,height = 1600,units = "px",limitsize = FALSE,device = cairo_pdf) 184 | ui_done("Volcano of {names(gsvadiff_list)[x]} GSVA analysis by limma is plot in {usethis::ui_path(volcano_file)}") 185 | 186 | })) 187 | 188 | } 189 | -------------------------------------------------------------------------------- /R/Visualization_DEG.R: -------------------------------------------------------------------------------- 1 | #' Heatmap for DEG data frame 2 | #' 3 | #' default will return a top 100 deg heatmap in p value = 0.05 4 | #' 5 | #' @param object a counts data frame of rows in genes and columns in samples 6 | #' @param top a single number or a length of 2 numeric vector, if 2 numeric vector, first one is top max logFC. 7 | #' @param which which model of deg analysis. kinds of DEG; can be "limma", "edgeR", "DESeq2" or "MSigDB" 8 | #' @param palette a color palette for plots 9 | #' @param filename NA or a file path 10 | #' @param show_gene logical,show gene name 11 | #' @param category MSigDB collection abbreviation, such as H or C1. 12 | #' @param ... More \code{\link[pheatmap]{pheatmap}} parameters. 13 | #' 14 | #' @importFrom edgeR cpm 15 | #' @importFrom pheatmap pheatmap 16 | #' @importFrom glue glue 17 | #' 18 | #' @return a heatmap plot file 19 | #' @export 20 | #' 21 | #' @examples 22 | #' DEGtopHeatmap(object,which = "limma") 23 | DEGtopHeatmap <- function(object, which, top = 50, filename = NA, show_gene = TRUE,category = "H", 24 | palette = RColorBrewer::brewer.pal(3,"Set2")[1:2],...) { 25 | 26 | if (is.null(matrixFiltered(object))) { 27 | counts_data = expMatrix(object) 28 | } else { 29 | counts_data = matrixFiltered(object) 30 | } 31 | 32 | deg_data <- dataDEG(obj = object,which = which,category = category) 33 | 34 | group_list = groupInfo(object) 35 | x = FC_Identify(res = deg_data) 36 | y = pvalue_Identify(res = deg_data) 37 | top = top 38 | 39 | choose_gene <- topGene(object = object, topSig = top, which = which) 40 | 41 | filename = filename 42 | 43 | # exprSet=log2(edgeR::cpm(counts_data)+1) 44 | exprSet=cpm(counts_data, prior.count = 2, log = TRUE) 45 | choose_matrix=exprSet[choose_gene,] 46 | choose_matrix=t(scale(t(choose_matrix))) 47 | choose_matrix[choose_matrix>2]=2 48 | choose_matrix[choose_matrix< -2]= -2 49 | colD=data.frame(Groups=group_list) 50 | rownames(colD)=colnames(exprSet) 51 | names(palette) <- unique(group_list) 52 | pheatmap(choose_matrix,..., 53 | annotation_col = colD,fontsize = 12, 54 | width = (ncol(choose_matrix)*0.3+2.2) *2, 55 | height = 550/100*3*nrow(choose_matrix)/100, 56 | annotation_colors = list(Groups = palette),show_rownames = show_gene,border_color = NA, 57 | filename = filename) 58 | } 59 | 60 | #' Plot venn for a set of gene 61 | #' 62 | #' @param geneSets a list of gene sets 63 | #' @param palette palette 64 | #' 65 | #' @importFrom VennDiagram venn.diagram 66 | #' @importFrom ggplotify as.ggplot 67 | #' @importFrom cowplot as_grob 68 | #' 69 | #' @return a plot of venn 70 | #' @export 71 | #' 72 | #' @examples 73 | #' DEGvenn(geneSets) 74 | DEGvenn <- function(geneSets, palette = c('#1f78b4','#33a02c','#ff7f00')) { 75 | 76 | p = venn.diagram(x = geneSets, 77 | filename= NULL, 78 | disable.logging = FALSE, 79 | col=NA, 80 | fill=palette, 81 | cat.col=palette, 82 | cat.cex = 1, 83 | cat.dist = -0.15, 84 | rotation.degree = 0, 85 | main.cex = 1, 86 | cex=1, 87 | alpha = 0.5, 88 | reverse=TRUE) 89 | file.remove(dir(pattern = ("^VennDiagram.*log$"))) 90 | p = as.ggplot(as_grob(p)) 91 | 92 | return(p) 93 | 94 | } 95 | -------------------------------------------------------------------------------- /R/Visualization_gse.R: -------------------------------------------------------------------------------- 1 | #' gseKEGG bar plot 2 | #' 3 | #' plot for enrich_gsekegg result 4 | #' 5 | #' @param data a enrich_gsekegg result 6 | #' @param pvalue_cut filter by pvalue 7 | #' @param enrichmentScore_cut filter by enrichmentScore 8 | #' @param top top rows of up and down 9 | #' 10 | #' @import ggplot2 11 | #' @importFrom dplyr top_n mutate 12 | #' @importFrom forcats fct_reorder 13 | #' @importFrom RColorBrewer brewer.pal 14 | #' @importFrom shadowtext geom_shadowtext 15 | #' @importFrom ggnewscale new_scale_color 16 | #' 17 | #' @return ggplot ob 18 | #' @export 19 | #' 20 | #' @examples 21 | #' \dontrun{ 22 | #' test <- enrich_gsekegg(DEG_df,x = "log2FoldChange") 23 | #' geskegg_barplot(test) 24 | #' } 25 | GSEAbar <- function(res, top = 10) { 26 | 27 | dat <- res@result 28 | 29 | down_kegg <- dat[dat$enrichmentScore < 0,]; 30 | up_kegg <- dat[dat$enrichmentScore >= 0,]; 31 | 32 | 33 | down_kegg <- down_kegg[na.omit(order(down_kegg[, "pvalue"])[1:top]), ] 34 | up_kegg <- up_kegg[na.omit(order(up_kegg[, "pvalue"])[1:top]), ] 35 | 36 | dat=rbind(up_kegg,down_kegg) 37 | 38 | p <- ggplot(dat, 39 | aes(NES, fct_reorder(stringr::str_wrap(Description,25), NES), 40 | fill=qvalue)) + 41 | geom_col() + 42 | scale_fill_gradientn(colours=c("#b3eebe", 43 | "#46bac2", "#371ea3"), 44 | guide=guide_colorbar(reverse=TRUE)) + 45 | theme_dose(12) + 46 | xlab("Normalized Enrichment Score") + 47 | ylab(NULL) 48 | 49 | return(p) 50 | 51 | } 52 | 53 | #' plot gseKEGG plot 54 | #' 55 | #' plot gseKEGG plots by up and down 56 | #' 57 | #' @param res output from gse 58 | #' @param top filter top by pvalue 59 | #' @param pvalue_cut filter cut of pvalue 60 | #' @param enrichmentScore_cut filter cut of enrichmentScore 61 | #' 62 | #' @importFrom enrichplot gseaplot2 63 | #' @import ggplot2 64 | #' 65 | #' @return a list contains up and down 66 | #' @export 67 | #' 68 | #' @examples 69 | #' \dontrun{ 70 | #' gsekegg_res <- enrich_gsekegg(DEG_df,x = "log2FoldChange") 71 | #' plots_l <- enhance_gseplot(gsekegg_res) 72 | #' } 73 | GSEAplot <- function(res, top = 10) { 74 | 75 | data = res 76 | down_kegg<-data[data$enrichmentScore < 0,] 77 | up_kegg<-data[data$enrichmentScore >= 0,] 78 | 79 | down_kegg <- down_kegg[na.omit(order(down_kegg[, "pvalue"])[1:top]), ] 80 | up_kegg <- up_kegg[na.omit(order(up_kegg[, "pvalue"])[1:top]), ] 81 | # down_kegg <- res %>% top_n(-top,wt = pvalue) 82 | # up_kegg <- res %>% top_n(top,wt = pvalue) 83 | 84 | plot_gseplot <- function(data,data_ud,x) { 85 | gseaplot2(res,data_ud$ID[x], 86 | title=stringr::str_wrap(data_ud$Description[x],30),pvalue_table = FALSE,subplots = 1:3,color = "blue") %>% 87 | print() + 88 | labs(caption = paste(sprintf('Pvalue: %.3f _ P.adjust: %.3f', data_ud$pvalue[x], data_ud$p.adjust[x])))+ 89 | theme(plot.caption = element_text(family = "Times", size = 8, face = "italic", colour = "dodgerblue")) 90 | } 91 | 92 | if (nrow(down_kegg) > 0) { 93 | down_plots <- lapply(1:nrow(down_kegg), function(x) plot_gseplot(data, 94 | down_kegg, x)) 95 | } else { 96 | down_plots <- NULL 97 | } 98 | if (nrow(up_kegg) > 0) { 99 | up_plots <- lapply(1:nrow(up_kegg), function(x) plot_gseplot(data, 100 | up_kegg, x)) 101 | } else { 102 | up_plots <- NULL 103 | } 104 | 105 | resl <- list(up_plots, down_plots) 106 | 107 | names(resl) <- c("up_plots", "down_plots") 108 | 109 | return(resl) 110 | 111 | } 112 | -------------------------------------------------------------------------------- /R/createOB.R: -------------------------------------------------------------------------------- 1 | #' create \code{dataInfo} 2 | #' 3 | #' a function to create \code{\link{dataInfo}} OB 4 | #' 5 | #' @param species species for your data. `Human` or `Mouse` 6 | #' @param dataType kind of expresses value matrix. `Counts` (Integer) or `Array` (Decimal). 7 | #' @param idType kind of gene id. `ENSEMBL` or `SYMBOL`, If `ENSEMBL`, it will be automatically converted to `SYMBOL`. 8 | #' @param expMatrix expresses value matrix. Should be a data.frame row named by gene ID and column named by Sample 9 | #' @param groupInfo a Character Vectors ordered by samples in matrix. 10 | #' @param caseGroup a Character names of case group. 11 | #' @param filterMethod a function used to filter expresses value matrix. 12 | #' @param matrixFiltered a expresses value matrix after filter by `filterMethod`. 13 | #' 14 | #' @importFrom methods new 15 | #' 16 | #' @return dataInfo 17 | #' @export 18 | Create_dataInfo <- function(species, 19 | dataType, 20 | idType, 21 | expMatrix, 22 | groupInfo, 23 | caseGroup, 24 | filterMethod, 25 | matrixFiltered) { 26 | 27 | species = as.character(species) 28 | dataType = as.character(dataType) 29 | idType = as.character(idType) 30 | expMatrix = as.data.frame(expMatrix) 31 | groupInfo = as.character(groupInfo) 32 | caseGroup = as.character(caseGroup) 33 | filterMethod = as.character(filterMethod) 34 | matrixFiltered = as.data.frame(matrixFiltered) 35 | 36 | 37 | new("dataInfo", 38 | species = species, 39 | dataType = dataType, 40 | idType = idType, 41 | expMatrix = expMatrix, 42 | groupInfo = groupInfo, 43 | caseGroup = caseGroup, 44 | filterMethod = filterMethod, 45 | matrixFiltered = matrixFiltered 46 | ) 47 | 48 | } 49 | 50 | # Low level function to create DEGContainer ------------------------------- 51 | #' @title Initialize an object of class \code{DEGContainer} 52 | #' 53 | #' @name newDEGContainer 54 | #' @docType methods 55 | #' 56 | #' @description Constructs a \code{DEGContainer} object. Additional helper 57 | #' methods for manipulating \code{DEGContainer} objects are also 58 | #' described below. We now recommend using 59 | #' \code{Create_DEGContainer} to create objects, instead. 60 | #' 61 | #' @param dataInfo a dataInfo object 62 | #' @param degResults a degResults object 63 | #' @param hyperResults a hyperResults object 64 | #' @param gseResults a gseResults object 65 | #' @param MSigDB a MSigDB object 66 | #' 67 | #' @return a DEGContainer 68 | #' 69 | #' @export 70 | newDEGContainer <- function(dataInfo=NULL, 71 | degResults=NULL, 72 | hyperResults=NULL, 73 | gseResults=NULL, 74 | MSigDB = NULL) 75 | { 76 | 77 | new( 78 | "DEGContainer", 79 | dataInfo=dataInfo, 80 | degResults=degResults, 81 | hyperResults=hyperResults, 82 | gseResults=gseResults, 83 | MSigDB = MSigDB 84 | ) 85 | 86 | } 87 | 88 | ## results OB create 89 | #' Function for treatInfo 90 | #' 91 | #' @param cutFC a numeric or list. Threshold of logFC for finding significantly different genes. 92 | #' @param cutFDR a numeric. Threshold of Pvalue for finding significantly different genes. 93 | #' @param label a character vector. Name for every group 94 | #' @param label_ns a character. Name of no signification group 95 | #' @param sigCol a character vector. sigColor of every group 96 | #' @param sigAlpha a numeric vector. transparency for every group 97 | #' 98 | #' @return treatInfo 99 | #' @export 100 | Create_treatInfo <- function(cutFC = NULL, 101 | cutFDR = 0.05, 102 | label = c("Down","Stable","Up"), 103 | label_ns = "Stable", 104 | sigCol = c("#2874C5", "grey", "#f87669"), 105 | sigAlpha = c(1,0.5,1), 106 | sigSize = c(0.6,0.5,0.6), 107 | sigShape = 16) { 108 | 109 | new("treatInfo", 110 | cutFC = cutFC, 111 | cutFDR = cutFDR, 112 | label = label, 113 | label_ns = label_ns, 114 | sigCol = sigCol, 115 | sigAlpha = sigAlpha, 116 | sigSize = sigSize, 117 | sigShape = sigShape 118 | ) 119 | 120 | } 121 | 122 | ## Create zero data frame for start 123 | Create_vsData <- function(limma,edgeR,DESeq2) { 124 | 125 | limma <- data.frame(matrix(ncol = 0, nrow = 0)) 126 | # colnames(limma) <- c("logFC","AveExpr","t","P.Value","adj.P.Val","B") 127 | 128 | edgeR <- data.frame(matrix(ncol = 0, nrow = 0)) 129 | # colnames(edgeR) <- c("logFC","logCPM","LR","PValue","FDR") 130 | 131 | DESeq2 <- data.frame(matrix(ncol = 0, nrow = 0)) 132 | # colnames(DESeq2) <- c("baseMean","log2FoldChange","lfcSE","stat","pvalue","padj") 133 | 134 | new("vsData", 135 | limma_res = limma, 136 | edgeR_res = edgeR, 137 | DESeq2_res = DESeq2) 138 | 139 | } 140 | 141 | Create_degResults <- function(vsData,treatInfo = Create_treatInfo()) { 142 | 143 | new("degResults", 144 | vsData = vsData, 145 | treatInfo = treatInfo 146 | ) 147 | 148 | } 149 | 150 | Create_hyperResults <- function(hyperParam=Create_hyperParam()) { 151 | 152 | new("hyperResults", 153 | hyperRes = list(), 154 | hyperParam = hyperParam 155 | ) 156 | 157 | } 158 | 159 | Create_gseResults <- function(gseParam=Create_gseParam()) { 160 | 161 | new("gseResults", 162 | gseRes = list(), 163 | gseParam = gseParam 164 | ) 165 | 166 | } 167 | 168 | #' Create \code{MSigDB} 169 | #' 170 | #' Create a MSigDB object. 171 | #' 172 | #' @param msigdbParam from \code{Create_msigdbParam} 173 | #' @param msigdbGSEAparam from \code{Create_msigdbGSEAparam} 174 | #' @param msigdbHyperParam from \code{Create_msigdbHyperParam} 175 | #' 176 | #' @return a \code{MSigDB} object 177 | #' @export 178 | Create_MSigDB <- function(msigdbParam = Create_msigdbParam(), 179 | msigdbGSEAparam = Create_msigdbGSEAparam(), 180 | msigdbHyperParam = Create_msigdbHyperParam()) { 181 | 182 | new("MSigDB", 183 | msigdbParam = msigdbParam, 184 | msigdbData = list(), 185 | msigdbGSEAparam = msigdbGSEAparam, 186 | msigdbHyperParam = msigdbHyperParam, 187 | msigdbGSEAresult = list(), 188 | msigdbHyperResult = list(), 189 | msigdbGSVAresult = list(), 190 | msigdbTreat = Create_treatInfo(cutFDR = 1)) 191 | 192 | } 193 | -------------------------------------------------------------------------------- /R/degGroup.R: -------------------------------------------------------------------------------- 1 | #' Group degResults 2 | #' 3 | #' group results of DEG analysis 4 | #' 5 | #' @param obj a DEGContainer 6 | #' 7 | #' @return a DEGContainer 8 | #' @export 9 | #' 10 | #' @examples 11 | #' degGroup(DEGContainer) 12 | setGeneric(name="degGroup", def=function(obj) standardGeneric("degGroup")) 13 | setMethod(f="degGroup", signature="DEGContainer", definition=function(obj) { 14 | 15 | test <- deg_here(obj) 16 | 17 | ok <- names(test)[which(test == TRUE)] 18 | 19 | main <- setdiff(ok,"merge") 20 | merge_data <- intersect(ok,"merge") 21 | 22 | if(length(main)>=1){ 23 | 24 | for (i in main) { 25 | 26 | obj <- cutMuch(obj,which = i) 27 | 28 | } 29 | 30 | } else { 31 | ui_info("None available results of DEG.") 32 | } 33 | 34 | if (length(main)>=2) { 35 | 36 | merge_res(obj) <- merge_deg(obj) 37 | 38 | ui_done("Common Genes updated") 39 | 40 | } 41 | 42 | return(obj) 43 | 44 | }) 45 | 46 | setMethod(f="degGroup", signature="MSigDB", definition=function(obj) { 47 | 48 | main = names(msigdbGSVAresult(obj)[['GSVA_diff']]) 49 | 50 | if(length(main)>=1){ 51 | 52 | for (i in main) { 53 | 54 | obj <- cutMuch(obj,which = "MSigDB",category = i) 55 | 56 | } 57 | 58 | } else { 59 | ui_info("None available results of MSigDB DEG analysis.") 60 | } 61 | 62 | return(obj) 63 | 64 | }) 65 | -------------------------------------------------------------------------------- /R/degResolveArray.R: -------------------------------------------------------------------------------- 1 | #' run DEG minimal 2 | #' 3 | #' run DEG module in limma, DESeq2 and edgeR 4 | #' 5 | #' @param object a DEGContainer contains at least dataInfo 6 | #' @param dir a directory to store results 7 | #' @param parallel if FALSE, no parallelization. if TRUE, parallel execution using BiocParallel 8 | #' 9 | #' @importFrom fs dir_exists dir_create 10 | #' @importFrom glue glue 11 | #' @importFrom utils write.csv 12 | #' @importFrom usethis ui_done 13 | #' 14 | #' @return a csv file and a DEG_container ob 15 | #' @export 16 | #' 17 | #' @examples 18 | #' \dontrun{ 19 | #' degResolve(counts_input,group_list,case_group = "T", control_group = "C",dir = tempdir()) 20 | #' } 21 | degResolveArray <- function(object,dir = ".", prefix = "2-DEG") { 22 | 23 | if (!fs::dir_exists(dir)) { 24 | fs::dir_create(dir) 25 | } 26 | 27 | if (is.null(matrixFiltered(object))) { 28 | expr_data = expMatrix(object) 29 | } else { 30 | expr_data = matrixFiltered(object) 31 | } 32 | 33 | group_list = groupInfo(object) 34 | case_group = caseGroup(object) 35 | control_group = setdiff(group_list,case_group) 36 | 37 | # usethis::ui_info(glue("Start DESeq2 analysis.")) 38 | # deg_df_DESeq2 <- DESeq2_resolve(expr_data,group_list,parallel = parallel,dir=dir,prefix = prefix, 39 | # case_group = case_group, control_group = control_group, qc = qc) 40 | 41 | # usethis::ui_info(glue("Start edgeR analysis.")) 42 | # deg_df_edgeR <- edgeR_resolveArray(expr_data, group_list, 43 | # control_group = control_group) 44 | 45 | usethis::ui_info(glue("Start limma analysis.")) 46 | deg_df_limma <- limma_resolveArray(expr_data,group_list, 47 | case_group = case_group, control_group = control_group) 48 | 49 | # usethis::ui_info(glue("Merge data above.")) 50 | # allg <- Reduce(intersect, list( 51 | # rownames(deg_df_edgeR), 52 | # rownames(deg_df_limma))) 53 | # 54 | # deg_df_intersect=cbind(deg_df_limma[allg,c("logFC","P.Value","adj.P.Val")], 55 | # deg_df_edgeR[allg,c("logFC","PValue","FDR")]) 56 | # 57 | # colnames(deg_df_intersect) <- paste0(colnames(deg_df_intersect),"_",rep(c("limma","edgeR"),each=2)) 58 | 59 | # csv_name = glue('{dir}/{prefix}_intersect_results.csv') 60 | # write.csv(deg_df_intersect,file = csv_name) 61 | # ui_done(glue("DEG results in csv format is stored in {usethis::ui_path(csv_name)}")) 62 | 63 | limma_res(object) = deg_df_limma 64 | # edgeR_res(object) = deg_df_edgeR 65 | # DESeq2_res(object) = deg_df_DESeq2 66 | # merge_res(object) = deg_df_intersect 67 | ui_done(glue("DEG results is updated in {ui_code('DEGContainer')}")) 68 | # rdata_name = glue('{dir}/{prefix}_results.Rdata') 69 | # save(deg_results,file = rdata_name) 70 | # ui_done(glue("DEG results in Rdata is stored in {usethis::ui_path(rdata_name)}")) 71 | 72 | 73 | 74 | return(object) 75 | 76 | } 77 | 78 | #' Basic produce of limma 79 | #' 80 | #' A basic function to get data and produce results of limma 81 | #' 82 | #' @param expr_data a counts data frame of rows in genes and columns in samples 83 | #' @param group_list a character vector ordered by samples in counts_data 84 | #' @param case_group the name of the numerator level for the fold change (Test group) 85 | #' @param control_group the name of the denominator level for the fold change (Control group) 86 | #' 87 | #' @importFrom stats model.matrix na.omit 88 | #' @importFrom edgeR DGEList cpm calcNormFactors 89 | #' @importFrom limma voom lmFit makeContrasts contrasts.fit eBayes topTable 90 | #' 91 | #' @return a DEG data frame 92 | #' @export 93 | #' 94 | #' @examples 95 | #' limma_resolve(counts_input, group_list, control_group= "C", case_group = "T") 96 | limma_resolveArray <- function(expr_data, group_list, control_group, case_group) { 97 | 98 | design <- model.matrix(~0+factor(group_list)) 99 | colnames(design)=levels(factor(group_list)) 100 | rownames(design)=colnames(expr_data) 101 | 102 | fit <- lmFit(expr_data, design) 103 | 104 | con=paste0(case_group,'-',control_group) 105 | 106 | cont.matrix=makeContrasts(contrasts=c(con),levels = design) 107 | fit2=contrasts.fit(fit,cont.matrix) 108 | fit2=eBayes(fit2) 109 | 110 | tempOutput = topTable(fit2, coef=con, number=Inf) 111 | DEG_limma_voom = na.omit(tempOutput) 112 | 113 | return(DEG_limma_voom) 114 | 115 | } 116 | -------------------------------------------------------------------------------- /R/degSummary.R: -------------------------------------------------------------------------------- 1 | #' Summary results of DEG analysis 2 | #' 3 | #' @param obj a DEGContainer object 4 | #' @param dir a directory to store results 5 | #' @param prefix a prefix of file names in this step 6 | #' @param PointVolcanoParam more parameters for \code{\link{PointVolcano}} 7 | #' 8 | #' @return a batch of files 9 | #' @export 10 | #' 11 | #' @examples 12 | #' degSummary(DEGContainer) 13 | degSummary <- function(obj, dir = ".", prefix = "2-runDEG", 14 | PointVolcanoParam = list(gene = 10,light = NULL, 15 | light_color = "#24ac56", 16 | light_label_color = "#24ac56", 17 | expend = c(0.12, 0.12))) { 18 | 19 | ## create dir if not exists 20 | if (!fs::dir_exists(dir)) { 21 | fs::dir_create(dir) 22 | } 23 | 24 | ## check deg results 25 | test <- deg_here(obj) 26 | ok <- names(test)[which(test == TRUE)] 27 | ## except merge 28 | main <- setdiff(ok,"merge") 29 | 30 | ## when merge exists 31 | if(test["merge"]) { 32 | 33 | dat <- dataDEG(obj,which = "merge") 34 | csv_name = glue('{dir}/{prefix}_merge_results.csv') 35 | write.csv(dat,file = csv_name) 36 | ui_done(glue("merge DEG results in csv format is stored in {usethis::ui_path(csv_name)}")) 37 | 38 | geneSymbol_list <- hyper_GS(obj,"merge",type = "SYMBOL") 39 | lapply(seq_along(geneSymbol_list), function(x){ 40 | 41 | file_name <- glue("{dir}/{prefix}_{names(geneSymbol_list)[x]}_merge_Gene.txt") 42 | writeLines(geneSymbol_list[[x]],con = file_name) 43 | ui_done(glue("merge {names(geneSymbol_list)[x]} Gene in txt format is stored in {usethis::ui_path(file_name)}")) 44 | 45 | }) 46 | 47 | } 48 | 49 | ## other dataset 50 | if(length(main)>=1){ 51 | 52 | for (i in main) { 53 | 54 | which = i 55 | 56 | geneSymbol_list <- hyper_GS(object = obj,which = which,type = "SYMBOL") 57 | ## gene names of every regulate group 58 | lapply(seq_along(geneSymbol_list), function(x){ 59 | 60 | file_name <- glue("{dir}/{prefix}_{names(geneSymbol_list)[x]}_{which}_Gene.txt") 61 | writeLines(geneSymbol_list[[x]],con = file_name) 62 | ui_done(glue("{which} {names(geneSymbol_list)[x]} Gene in txt format is stored in {usethis::ui_path(file_name)}")) 63 | 64 | }) 65 | 66 | ## deg results 67 | dat <- dataDEG(obj,which = which) 68 | csv_name = glue('{dir}/{prefix}_{which}_results.csv') 69 | write.csv(dat,file = csv_name) 70 | ui_done(glue("{which} DEG results in csv format is stored in {usethis::ui_path(csv_name)}")) 71 | 72 | ## volcano plot 73 | volcano_plot <- do.call("PointVolcano",c(list(obj = obj,which = i), PointVolcanoParam)) 74 | volcano_file = glue("{dir}/{prefix}_{which}_volcano.pdf") 75 | ggsave(volcano_plot,filename = volcano_file, width = 1600,height = 1600,units = "px",limitsize = FALSE,device = cairo_pdf) 76 | ui_done(glue("{which} volcano results were store in {ui_path(volcano_file)}.")) 77 | 78 | topHeatmap_file = glue("{dir}/{prefix}_{which}_top500_heatmap.pdf") 79 | topHeatmap <- do.call("DEGtopHeatmap",list(obj = obj,which = i,filename = topHeatmap_file)) 80 | ui_done(glue("{which} top 500 heatmap were store in {ui_path(topHeatmap_file)}.")) 81 | 82 | } 83 | 84 | ## top heatmap all 85 | heatmap_ls <- lapply(main, function(x){ 86 | 87 | do.call("DEGtopHeatmap",list(obj = obj, which = x,filename = NA,show_gene = FALSE, 88 | legend = FALSE,annotation_legend = FALSE,annotation_names_col = F)) 89 | 90 | }) 91 | heatmap_all <- aplot::plot_list(gglist = heatmap_ls,labels = main,guides = 'collect') 92 | heatmap_all_file = glue("{dir}/{prefix}_ALL_top500heatmap.pdf") 93 | ggsave(filename = heatmap_all_file,plot = heatmap_all,device = cairo_pdf,width = 4.5*length(main),height = 4.5) 94 | ui_done(glue("DEG top heatmap plot were store in {ui_path(heatmap_all_file)}.")) 95 | 96 | ## venn plot 97 | if (length(main) > 1) { 98 | index <- c(setdiff(label(obj),label_ns(obj)),"diff") 99 | 100 | geneSets <- lapply(main, function(x){ 101 | geneSymbol_list <- hyper_GS(object = obj,which = x,type = "SYMBOL") 102 | }) 103 | names(geneSets) <- main 104 | 105 | geneSets_ls <- list() 106 | for (i in index){ 107 | tmp <- lapply(main, function(x){geneSets[[x]][[i]]}) 108 | names(tmp) <- main 109 | geneSets_ls[[i]] <- tmp 110 | } 111 | 112 | p_list <- lapply(seq_along(geneSets_ls), function(x){ 113 | DEGvenn(geneSets = geneSets_ls[[x]]) 114 | }) 115 | p_l <- aplot::plot_list(gglist = p_list,labels = index) 116 | 117 | venn_file = glue("{dir}/{prefix}_vennplot.pdf") 118 | ggsave(filename = venn_file,plot = p_l,device = cairo_pdf,width = 4.5*length(index),height = 4.5) 119 | ui_done(glue("DEG venn plot were store in {ui_path(venn_file)}.")) 120 | } 121 | 122 | } else { 123 | ui_info("None available results of DEG.") 124 | } 125 | 126 | } 127 | -------------------------------------------------------------------------------- /R/gseResolve.R: -------------------------------------------------------------------------------- 1 | #' GSEA analysis 2 | #' 3 | #' @param object a DEGContainer 4 | #' @param GO run GO database 5 | #' @param KEGG run KEGG database 6 | #' 7 | #' @return a DEGContainer 8 | #' @export 9 | #' 10 | #' @examples 11 | #' gseResolve(DEGContainer) 12 | gseResolve <- function(object, GO = FALSE, KEGG = TRUE) { 13 | 14 | ## 获取GeneList 15 | test <- deg_here(object) 16 | ok <- names(test)[which(test == TRUE)] ## 取有效数据 17 | 18 | if (is.null(gseGOparam)) { 19 | GO = FALSE 20 | } 21 | 22 | if (is.null(gseKEGGparam)) { 23 | KEGG = FALSE 24 | } 25 | 26 | OrgDb = gseGOparam(object)[["OrgDb"]] 27 | 28 | if(KEGG) { 29 | 30 | usethis::ui_info("GSE KEGG analysis Start. This process will take a few minutes.") 31 | 32 | keggParams <- gseKEGGparam(object) 33 | gseKEGG_GeneSets = list() 34 | 35 | if("TERM2GENE" %in% names(keggParams)){ 36 | for (i in ok) { 37 | gseKEGG_GeneSets[[i]] <- suppressWarnings(GSEA_GS(object,which = i,type = "SYMBOL")) 38 | } 39 | } else { 40 | for (i in ok) { 41 | gseKEGG_GeneSets[[i]] <- suppressWarnings(GSEA_GS(object,which = i,type = "ENTREZID",OrgDb = OrgDb)) 42 | } 43 | } 44 | 45 | ## 富集分析 46 | gseKEGG_res <- gse_keggResolve(geneSet_list = gseKEGG_GeneSets,keggParams = keggParams) 47 | 48 | } else { 49 | 50 | gseKEGG_res <- NULL 51 | 52 | } 53 | 54 | if(GO) { 55 | 56 | usethis::ui_info("GSE GO analysis Start. This process will take a few minutes.") 57 | 58 | goParams <- gseGOparam(object) 59 | gseGO_GeneSets = list() 60 | 61 | for (i in ok) { 62 | gseGO_GeneSets[[i]] <- suppressWarnings(GSEA_GS(object,which = i,type = "SYMBOL")) 63 | } 64 | 65 | ## 富集分析 66 | gseGO_res <- gse_goResolve(geneSet_list = gseGO_GeneSets,goParams = goParams) 67 | 68 | } else { 69 | 70 | gseGO_res = NULL 71 | 72 | } 73 | 74 | 75 | ## 保存结果 76 | tmp <- gseRes(object) 77 | tmp["gseKEGG_res"] <- list(gseKEGG_res) 78 | tmp["gseGO_res"] <- list(gseGO_res) 79 | gseRes(object) <- tmp 80 | 81 | return(object) 82 | } 83 | 84 | #' @importFrom clusterProfiler gseKEGG 85 | #' @export 86 | gse_keggResolve <- function(...,geneSet_list,keggParams) { 87 | 88 | keggres <- lapply(seq_along(geneSet_list), function(x){ 89 | 90 | gene = geneSet_list[[x]] 91 | 92 | tryCatch( 93 | expr = { 94 | gseCore(gene=gene,fparams=keggParams,f = "gseKEGG") 95 | }, 96 | error = function(e){ 97 | usethis::ui_oops("Something wrong occured. try again.") 98 | gseCore(gene=gene,fparams=keggParams,f = "gseKEGG") 99 | }, 100 | finally = { 101 | usethis::ui_line("GSE KEGG {names(geneSet_list)[x]} analysis done") 102 | } 103 | ) 104 | 105 | }) 106 | 107 | names(keggres) <- names(geneSet_list) 108 | 109 | return(keggres) 110 | 111 | } 112 | 113 | #' @importFrom clusterProfiler gseGO 114 | #' @export 115 | gse_goResolve <- function(...,geneSet_list,goParams) { 116 | 117 | gores <- lapply(seq_along(geneSet_list), function(x){ 118 | 119 | gene = geneSet_list[[x]] 120 | 121 | tryCatch( 122 | expr = { 123 | gseCore(gene=gene,fparams=goParams,f = "gseGO") 124 | }, 125 | error = function(e){ 126 | usethis::ui_oops("Something wrong occured. try again.") 127 | gseCore(gene=gene,fparams=goParams,f = "gseGO") 128 | }, 129 | finally = { 130 | usethis::ui_line("GSE GO {names(geneSet_list)[x]} analysis done") 131 | } 132 | ) 133 | 134 | }) 135 | 136 | names(gores) <- names(geneSet_list) 137 | 138 | return(gores) 139 | 140 | } 141 | 142 | #' @importFrom clusterProfiler gseKEGG GSEA 143 | gseCore <- function(..., fparams, f = "gseKEGG") { 144 | 145 | params <- list(...) 146 | fparams <- modifyList(params, fparams) 147 | f2 = "GSEA" 148 | f3 = "gseGO2" 149 | 150 | if("ont" %in% names(fparams)&"TERM2GENE" %in% names(fparams)){ 151 | 152 | core <- suppressMessages(do.call(f3, modifyList( 153 | list(), 154 | fparams) 155 | )) 156 | 157 | } else if ("TERM2GENE" %in% names(fparams)&!"ont" %in% names(fparams)) { 158 | 159 | core <- suppressMessages(do.call(f2, modifyList( 160 | list(), 161 | fparams) 162 | )) 163 | 164 | } else { 165 | 166 | core <- suppressMessages(do.call(f, modifyList( 167 | list(), 168 | fparams) 169 | )) 170 | 171 | } 172 | 173 | return(core) 174 | 175 | } 176 | -------------------------------------------------------------------------------- /R/gseSummary.R: -------------------------------------------------------------------------------- 1 | #' Summary GSE results 2 | #' 3 | #' @param obj a DEGContainer 4 | #' @param dir a directory to store results 5 | #' @param prefix a prefix of file names in this step 6 | #' @param top top rows of up and down 7 | #' 8 | #' @return files 9 | #' @export 10 | #' 11 | #' @examples 12 | #' gseSummary(DEGContainer) 13 | gseSummary <- function(obj, dir = ".", prefix = "4-runGSEA",top =10) { 14 | 15 | if (!fs::dir_exists(dir)) { 16 | fs::dir_create(dir) 17 | } 18 | 19 | ## get data 20 | # ui_info("Start summary ") 21 | res_list <- gseRes(obj = obj)$gseKEGG_res 22 | 23 | if(!is.null(res_list)){ 24 | # ## KEGG data 25 | ## 条形图 26 | plot_list <- lapply(seq_along(res_list), function(i){ 27 | x = res_list[[i]] 28 | GSEAbar(x,top = top) + 29 | theme(legend.position="none") + 30 | ggtitle(names(res_list)[i]) 31 | 32 | }) 33 | 34 | legend <- cowplot::get_legend( 35 | # create some space to the left of the legend 36 | plot_list[[1]] + ggplot2::theme(legend.position="right",legend.box.margin = ggplot2::margin(0, 0, 0, 12)) 37 | ) 38 | 39 | p <- cowplot::plot_grid(plotlist = plot_list,legend,ncol = 5, rel_widths = c(.4,3,3,3,3)) 40 | 41 | ggplot2::ggsave(p,filename = glue::glue("{dir}/{prefix}_KEGG_bar.pdf"), width = 6400,height = 1200*(top*2/10),units = "px",limitsize = FALSE,device = cairo_pdf) 42 | 43 | ## 趋势图 44 | tmp <- lapply(seq_along(res_list), function(i){ 45 | 46 | x = res_list[[i]] 47 | 48 | gseaplots_l <- GSEAplot(x,top =top) 49 | 50 | ## 保存gse富集趋势图到多页pdf 51 | mod <- names(res_list)[i] 52 | down_plots_pdf <- glue("{dir}/{prefix}_KEGG_{mod}_Down_gseplot.pdf") 53 | pdf(down_plots_pdf,height = 3,width = 4) 54 | invisible(lapply(gseaplots_l[["down_plots"]], print)) 55 | dev.off() 56 | ui_done(glue("Enrichplot of KEGG head {top} {mod} in Down ploted in {ui_path({down_plots_pdf})}")) 57 | 58 | up_plots_pdf <- glue("{dir}/{prefix}_KEGG_{mod}_Up_gseplot.pdf") 59 | pdf(up_plots_pdf,height = 3,width = 4) 60 | invisible(lapply(gseaplots_l[["up_plots"]], print)) 61 | dev.off() 62 | ui_done(glue("Enrichplot of KEGG head {top} {mod} in Up ploted in {ui_path({up_plots_pdf})}")) 63 | 64 | }) 65 | 66 | ## csv 67 | tmp <- lapply(seq_along(res_list), function(i){ 68 | 69 | res <- res_list[[i]] 70 | dat <- res@result 71 | 72 | res_name <- glue("{dir}/{prefix}_KEGG_{names(res_list)[i]}.csv") 73 | write.csv(dat,file = res_name) 74 | ui_done(glue("{names(res_list)[i]} GSE KEGG result in csv format is stored in {usethis::ui_path(res_name)}")) 75 | 76 | }) 77 | } 78 | 79 | res_list <- gseRes(obj = obj)$gseGO_res 80 | 81 | if(!is.null(res_list)){ 82 | 83 | # ## GO data 84 | ## 条形图 85 | plot_list <- lapply(seq_along(res_list), function(i){ 86 | x = res_list[[i]] 87 | GSEAbar(x,top = top) + 88 | theme(legend.position="none") + 89 | ggtitle(names(res_list)[i]) 90 | 91 | }) 92 | 93 | legend <- cowplot::get_legend( 94 | # create some space to the left of the legend 95 | plot_list[[1]] + ggplot2::theme(legend.position="right",legend.box.margin = ggplot2::margin(0, 0, 0, 12)) 96 | ) 97 | 98 | p <- cowplot::plot_grid(plotlist = plot_list,legend,ncol = 5, rel_widths = c(.4,3,3,3,3)) 99 | 100 | ggplot2::ggsave(p,filename = glue::glue("{dir}/{prefix}_GO_bar.pdf"), width = 6400,height = 1200*(top*2/10),units = "px",limitsize = FALSE,device = cairo_pdf) 101 | 102 | 103 | ## 趋势图 104 | tmp <- lapply(seq_along(res_list), function(i){ 105 | 106 | x = res_list[[i]] 107 | 108 | gseaplots_l <- GSEAplot(x,top =top) 109 | 110 | ## 保存gse富集趋势图到多页pdf 111 | mod <- names(res_list)[i] 112 | down_plots_pdf <- glue("{dir}/{prefix}_GO_{mod}_Down_gseplot.pdf") 113 | pdf(down_plots_pdf,height = 3,width = 4) 114 | invisible(lapply(gseaplots_l[["down_plots"]], print)) 115 | dev.off() 116 | ui_done(glue("Enrichplot of GO head {top} {mod} in Down ploted in {ui_path({down_plots_pdf})}")) 117 | 118 | up_plots_pdf <- glue("{dir}/{prefix}_GO_{mod}_Up_gseplot.pdf") 119 | pdf(up_plots_pdf,height = 3,width = 4) 120 | invisible(lapply(gseaplots_l[["up_plots"]], print)) 121 | dev.off() 122 | ui_done(glue("Enrichplot of GO head {top} {mod} in Up ploted in {ui_path({up_plots_pdf})}")) 123 | 124 | }) 125 | 126 | ## csv 127 | tmp <- lapply(seq_along(res_list), function(i){ 128 | 129 | res <- res_list[[i]] 130 | if (!is.null(res)) {dat <- res@result} 131 | 132 | res_name <- glue("{dir}/{prefix}_GO_{names(res_list)[i]}.csv") 133 | write.csv(dat,file = res_name) 134 | ui_done(glue("{names(res_list)[i]} GSE GO result in csv format is stored in {usethis::ui_path(res_name)}")) 135 | 136 | }) 137 | 138 | } 139 | 140 | 141 | } 142 | -------------------------------------------------------------------------------- /R/hyperResolve.R: -------------------------------------------------------------------------------- 1 | #' Resolve Hyper 2 | #' 3 | #' @param object DEGContainer 4 | #' @param GO run GO,TRUE or FALSE 5 | #' @param KEGG run KEGG,TRUE or FALSE 6 | #' 7 | #' @return DEGContainer 8 | #' @export 9 | #' 10 | #' @examples 11 | #' hyperResolve(object, GO = FALSE, KEGG = TRUE) 12 | hyperResolve <- function(object, GO = FALSE, KEGG = TRUE) { 13 | 14 | ## 获取GeneList 15 | test <- deg_here(object) 16 | ok <- names(test)[which(test == TRUE)] ## 取有效数据 17 | 18 | if (is.null(hyperGOparam)) { 19 | GO = FALSE 20 | } 21 | 22 | if (is.null(hyperKEGGparam)) { 23 | KEGG = FALSE 24 | } 25 | 26 | OrgDb <- hyperGOparam(object)[["OrgDb"]] 27 | 28 | if (KEGG) { 29 | 30 | usethis::ui_info("Enrich KEGG analysis Start. This process will take a few minutes.") 31 | 32 | ## get parameters 33 | keggParams <- hyperKEGGparam(object) 34 | hyperKEGG_GeneSets = list() 35 | 36 | ## 自定义数据集 使用 SYMBOL 37 | if("TERM2GENE" %in% names(keggParams)){ 38 | 39 | for (i in ok) { 40 | hyperKEGG_GeneSets[[i]] <- suppressWarnings(hyper_GS(object,which = i,type = "SYMBOL")) 41 | } 42 | 43 | } else { 44 | 45 | for (i in ok) { 46 | hyperKEGG_GeneSets[[i]] <- suppressWarnings(hyper_GS(object,which = i,type = "ENTREZID",OrgDb = OrgDb)) 47 | } 48 | 49 | } 50 | 51 | ## 富集分析 52 | hyperKEGG_res <- lapply(seq_along(hyperKEGG_GeneSets), function(x){ 53 | geneSet_list = hyperKEGG_GeneSets[[x]] 54 | res <- hyper_keggResolve(geneSet_list = geneSet_list,keggParams = keggParams) 55 | ui_done("Enrich KEGG {names(hyperKEGG_GeneSets)[x]} analysis done") 56 | 57 | return(res) 58 | }) 59 | 60 | names(hyperKEGG_res) <- names(hyperKEGG_GeneSets) 61 | 62 | } else { 63 | 64 | hyperKEGG_res <- NULL 65 | 66 | } 67 | 68 | if (GO) { 69 | 70 | usethis::ui_info("Enrich GO analysis Start. This process will take a few minutes.") 71 | 72 | goParams <- hyperGOparam(object) 73 | hyperGO_GeneSets = list() 74 | 75 | for (i in ok) { 76 | hyperGO_GeneSets[[i]] <- suppressWarnings(hyper_GS(object,which = i,type = "SYMBOL")) 77 | } 78 | 79 | ## 富集分析 80 | hyperGO_res <- lapply(seq_along(hyperGO_GeneSets), function(x){ 81 | geneSet_list = hyperGO_GeneSets[[x]] 82 | res <- hyper_goResolve(geneSet_list = geneSet_list,goParams = goParams) 83 | ui_done("Enrich GO {names(hyperGO_GeneSets)[x]} analysis done") 84 | return(res) 85 | }) 86 | 87 | names(hyperGO_res) <- names(hyperGO_GeneSets) 88 | 89 | } else { 90 | 91 | hyperGO_res <- NULL 92 | 93 | } 94 | 95 | ## 保存结果 96 | tmp <- hyperRes(object) 97 | tmp["hyperKEGG_res"] <- list(hyperKEGG_res) 98 | tmp["hyperGO_res"] <- list(hyperGO_res) 99 | hyperRes(object) <- tmp 100 | 101 | return(object) 102 | } 103 | 104 | #' @export 105 | hyper_keggResolve <- function(...,geneSet_list,keggParams) { 106 | 107 | keggres <- lapply(seq_along(geneSet_list), function(x){ 108 | 109 | gene = geneSet_list[[x]] 110 | 111 | tryCatch( 112 | expr = { 113 | hyperCore(gene=gene,fparams = keggParams,f = "enrichKEGG") 114 | }, 115 | error = function(e){ 116 | usethis::ui_oops("Something wrong occured. try again.") 117 | hyperCore(gene=gene,fparams = keggParams,f = "enrichKEGG") 118 | }, 119 | finally = { 120 | usethis::ui_line("Enrich KEGG {names(geneSet_list)[x]} analysis done") 121 | } 122 | ) 123 | 124 | }) 125 | 126 | names(keggres) <- names(geneSet_list) 127 | 128 | return(keggres) 129 | 130 | } 131 | 132 | #' @importFrom clusterProfiler enrichGO 133 | #' @export 134 | hyper_goResolve <- function(...,geneSet_list,goParams) { 135 | 136 | gores <- lapply(seq_along(geneSet_list), function(x){ 137 | 138 | gene = geneSet_list[[x]] 139 | 140 | tryCatch( 141 | expr = { 142 | hyperCore(gene=gene,fparams = goParams,f = "enrichGO") 143 | }, 144 | error = function(e){ 145 | usethis::ui_oops("Something wrong occured. try again.") 146 | hyperCore(gene=gene,fparams = goParams,f = "enrichGO") 147 | }, 148 | finally = { 149 | usethis::ui_line("Enrich GO {names(geneSet_list)[x]} analysis done") 150 | } 151 | ) 152 | 153 | }) 154 | 155 | names(gores) <- names(geneSet_list) 156 | 157 | return(gores) 158 | 159 | } 160 | 161 | #' @importFrom clusterProfiler enrichKEGG enricher 162 | hyperCore <- function(..., fparams, f = "enrichKEGG") { 163 | 164 | params <- list(...) 165 | fparams <- modifyList(params, fparams) 166 | f2 = "enricher" 167 | f3 = "enrichGO2" 168 | 169 | if("ont" %in% names(fparams)&"TERM2GENE" %in% names(fparams)){ 170 | 171 | core <- suppressMessages(do.call(f3, modifyList( 172 | list(), 173 | fparams) 174 | )) 175 | 176 | } else if ("TERM2GENE" %in% names(fparams)&!"ont" %in% names(fparams)) { 177 | 178 | core <- suppressMessages(do.call(f2, modifyList( 179 | list(), 180 | fparams) 181 | )) 182 | 183 | } else { 184 | 185 | core <- suppressMessages(do.call(f, modifyList( 186 | list(), 187 | fparams) 188 | )) 189 | 190 | } 191 | 192 | return(core) 193 | 194 | } 195 | -------------------------------------------------------------------------------- /R/hyperSummary.R: -------------------------------------------------------------------------------- 1 | #' Summary Hyper results 2 | #' 3 | #' @param obj a DEGContainer 4 | #' @param dir a directory to store results 5 | #' @param prefix a prefix of file names in this step 6 | #' @param top top rows of up and down 7 | #' 8 | #' @importFrom usethis ui_info 9 | #' @importFrom fs dir_create 10 | #' @importFrom cowplot plot_grid get_legend 11 | #' @importFrom ggplot2 ggsave 12 | #' 13 | #' @return files 14 | #' @export 15 | #' 16 | #' @examples 17 | #' hyperSummary(DEGContainer) 18 | hyperSummary <- function(obj, dir = ".", prefix = "3-runHyper",top = 10) { 19 | 20 | if (!fs::dir_exists(dir)) { 21 | fs::dir_create(dir) 22 | } 23 | 24 | pro = NULL 25 | 26 | if (length(hyperRes(obj)[["hyperKEGG_res"]]) > 0) { 27 | pro = "KEGG" 28 | } 29 | 30 | if (length(hyperRes(obj)[["hyperGO_res"]]) > 0) { 31 | pro = c(pro,"GO") 32 | } 33 | 34 | if(is.null(pro)){ 35 | 36 | ui_info("NO KEGG or GO data found!") 37 | 38 | } else { 39 | 40 | lapply(pro, function(x){ 41 | ui_info("Start to Summary Hyper {x}") 42 | 43 | ## Bar plot of Count, order by pvalue, fill by qvalue 44 | tryCatch( 45 | expr = { 46 | hyperSummaryHyperBar(obj = obj,dataBase = x,top = top,dir = dir,prefix = prefix) 47 | }, 48 | error = function(e){ 49 | usethis::ui_oops("Something wrong occured in hyperSummaryHyperBar {x}. 50 | try again later by {ui_code('hyperSummaryHyperBar')}.") 51 | } 52 | ) 53 | 54 | ## Circlize plot of KEGG ids in Different methods 55 | tryCatch( 56 | expr = { 57 | hyperSummaryHyperCompareCircle(obj = obj,dataBase = x,orderBy = "pvalue",top = top,dir = dir,prefix = prefix) 58 | }, 59 | error = function(e){ 60 | usethis::ui_oops("Something wrong occured in hyperSummaryHyperCompareCircle {x}. 61 | try again later by {ui_code('hyperSummaryHyperCompareCircle')}.") 62 | } 63 | ) 64 | 65 | ## CSV files for results 66 | tryCatch( 67 | expr = { 68 | hyperSummaryCSV(obj = obj, dataBase = x, dir = dir, prefix = prefix) 69 | }, 70 | error = function(e){ 71 | usethis::ui_oops("Something wrong occured in hyperSummaryCSV {x}. 72 | try again later by {ui_code('hyperSummaryCSV')}.") 73 | } 74 | ) 75 | 76 | if(identical(x,"GO")){ 77 | tryCatch( 78 | expr = { 79 | ## GO enrich barplot Split by Ontology 80 | hyperSummaryGOBar(obj = obj, top = top, dir = dir, prefix = prefix) 81 | }, 82 | error = function(e){ 83 | usethis::ui_oops("Something wrong occured in hyperSummaryGOBar. 84 | try again later by {ui_code('hyperSummaryGOBar')}.") 85 | } 86 | ) 87 | } 88 | 89 | }) 90 | 91 | } 92 | 93 | } 94 | 95 | ## Hyper Summary Enrich bar plot 96 | hyperSummaryGOBar <- function(obj,top = 10,dir = ".",prefix = "3-runHyper"){ 97 | 98 | index <- c(setdiff(label(obj),label_ns(obj)),"diff") 99 | ## get data 100 | # ui_info("Start plot") 101 | data <- hyperRes(obj = obj) 102 | 103 | subRes <- data$hyperGO_res 104 | 105 | if (is.null(subRes)) { 106 | 107 | ui_oops("NO data avalible of {ui_value('GO')}") 108 | 109 | } else { 110 | 111 | tmp <- lapply(index, function(i) { 112 | 113 | plot_list <- lapply(seq_along(subRes), function(j){ 114 | 115 | x = subRes[[j]] 116 | eob <- x[[i]] 117 | 118 | if(!is.null(eob)){ 119 | 120 | enrichBar(eob,top = top,plot_title = names(subRes)[j]) 121 | 122 | } else { 123 | 124 | ui_info("Hyper GO of {j} {i} Data not avalible") 125 | 126 | } 127 | 128 | }) 129 | 130 | p <- patchwork::wrap_plots(plot_list,nrow = 1,guides = "collect") 131 | 132 | plot_path = glue::glue("{dir}/{prefix}_GO_{i}_OntologySplitBar.pdf") 133 | ggplot2::ggsave(p,filename = plot_path, width = 2566.66*seq_along(subRes),height = 1800*(top*2/10),units = "px",limitsize = FALSE,device = cairo_pdf,dpi = 300) 134 | ui_done(glue("{i} Genes Hyper GO enrich barplot Split by Ontology is stored in {usethis::ui_path(plot_path)}")) 135 | 136 | }) 137 | 138 | } 139 | 140 | } 141 | 142 | ## CSV files for results 143 | hyperSummaryCSV <- function(obj,dataBase,dir = ".",prefix = "3-runHyper"){ 144 | 145 | if (missing(dataBase)) { 146 | 147 | ui_oops("Please select from {ui_value('KEGG')} or {ui_value('GO')} for ui_code('dataBase')") 148 | 149 | } 150 | 151 | index <- c(setdiff(label(obj),label_ns(obj)),"diff") 152 | ## get data 153 | # ui_info("Start plot") 154 | data <- hyperRes(obj = obj) 155 | 156 | if (dataBase == "KEGG") { 157 | subRes <- data$hyperKEGG_res 158 | } else if (dataBase == "GO") { 159 | subRes <- data$hyperGO_res 160 | } else { 161 | 162 | ui_oops("Please select from {ui_value('KEGG')} or {ui_value('GO')} for ui_code('dataBase')") 163 | 164 | } 165 | 166 | if (is.null(subRes)) { 167 | 168 | ui_oops("NO data avalible of {ui_value(dataBase)}") 169 | 170 | } else { 171 | 172 | tmp <- lapply(index, function(i){ ## Up Down diff 173 | 174 | lapply(seq_along(subRes), function(j){ ## limma edgeR DESeq2 175 | 176 | x = subRes[[j]] 177 | eob <- x[[i]] 178 | 179 | if (is.null(eob)) { 180 | 181 | ui_info("Hyper {dataBase} of {j} {i} Data not avalible") 182 | 183 | } else { 184 | 185 | res_name <- glue("{dir}/{prefix}_{dataBase}_{names(subRes)[j]}_{i}_Gene.csv") 186 | write.csv(eob@result,file = res_name) 187 | ui_done(glue("{names(subRes)[j]} {i} Hyper {dataBase} result in csv format is stored in {usethis::ui_path(res_name)}")) 188 | 189 | } 190 | 191 | }) 192 | 193 | }) 194 | 195 | } 196 | 197 | } 198 | 199 | ## Circlize plot of KEGG and GO in Different methods ---- 200 | hyperSummaryHyperCompareCircle <- function(obj,dataBase,orderBy = "pvalue",top = 10,dir = ".",prefix = "3-runHyper"){ 201 | 202 | index <- c(setdiff(label(obj),label_ns(obj)),"diff") 203 | ## check deg results 204 | test <- deg_here(obj) 205 | ok <- names(test)[which(test == TRUE)] 206 | ## except merge 207 | main <- setdiff(ok,"merge") 208 | 209 | ## convert data format for compareEnrichCircle 210 | res_l <- modelEnrich(obj,dataBase = dataBase,orderBy = orderBy,head = top) 211 | 212 | if (is.null(res_l)) { 213 | ui_oops("NO data avaliable for {ui_code('compareEnrichCircle')}") 214 | } else { 215 | tmp <- lapply(index, function(x){ 216 | tryCatch( 217 | expr = { 218 | dat_d <- res_l[[x]] 219 | cc_file_name = glue("{dir}/{prefix}_{dataBase}_compareEnrichCircle_{x}.pdf") 220 | compareEnrichCircle(result_g = dat_d,filename = cc_file_name,mar = c(8,0,0,19)) 221 | }, 222 | error = function(e){ 223 | usethis::ui_oops("Something wrong occured in {ui_code('compareEnrichCircle')} of {x}") 224 | } 225 | ) 226 | }) 227 | } 228 | 229 | } 230 | 231 | ## barplot of KEGG and GO ---- 232 | hyperSummaryHyperBar <- function(obj,dataBase,top = 10,dir=".",prefix = "3-runHyper"){ 233 | 234 | if (missing(dataBase)) { 235 | 236 | ui_oops("Please select from {ui_value('KEGG')} or {ui_value('GO')} for ui_code('dataBase')") 237 | 238 | } 239 | 240 | index <- c(setdiff(label(obj),label_ns(obj)),"diff") 241 | ## get data 242 | # ui_info("Start plot") 243 | data <- hyperRes(obj = obj) 244 | 245 | if (dataBase == "KEGG") { 246 | subRes <- data$hyperKEGG_res 247 | } else if (dataBase == "GO") { 248 | subRes <- data$hyperGO_res 249 | } else { 250 | 251 | ui_oops("Please select from {ui_value('KEGG')} or {ui_value('GO')} for ui_code('dataBase')") 252 | 253 | } 254 | 255 | if (is.null(subRes)) { 256 | 257 | ui_oops("NO data avalible of {ui_value(dataBase)}") 258 | 259 | } else { 260 | 261 | ## Down up diff split 262 | tmp <- lapply(index, function(i){ 263 | 264 | ## plot for every results 265 | plot_list <- lapply(seq_along(subRes), function(j){ 266 | 267 | tryCatch( 268 | expr = { 269 | 270 | ## get limma edgeR DESeq2 271 | x = subRes[[j]] 272 | ## get up down diff 273 | eob <- x[[i]] 274 | ## plot 275 | if(!is.null(eob)) { 276 | hyperBar(eob,top = top) + ggtitle(names(subRes)[j]) 277 | } else { 278 | ui_oops("NO data avalible of {ui_value(dataBase)} {ui_value(names(subRes)[j])} {ui_value(i)}") 279 | } 280 | 281 | }, 282 | error = function(e){ 283 | usethis::ui_oops("Something wrong occured in {ui_code('hyperBar')} {ui_value(names(subRes)[j])} {ui_value(i)}.") 284 | } 285 | ) 286 | 287 | }) 288 | 289 | ## collect plots 290 | p <- patchwork::wrap_plots(plot_list,nrow = 1,guides = "collect") 291 | 292 | ## save plot 293 | plot_path = glue::glue("{dir}/{prefix}_{dataBase}_{i}.pdf") 294 | ggplot2::ggsave(p,filename = plot_path, width = 6400,height = 1200*(top*2.5/10),units = "px",limitsize = FALSE,device = cairo_pdf) 295 | 296 | ui_done(glue("{i} Genes Hyper {dataBase} barplot is stored in {usethis::ui_path(plot_path)}")) 297 | 298 | }) 299 | 300 | } 301 | 302 | } 303 | -------------------------------------------------------------------------------- /R/msigdbResolve.R: -------------------------------------------------------------------------------- 1 | #' Download MSigDB data for DEGContainer 2 | #' 3 | #' @param object a DEGContainer 4 | #' 5 | #' @importFrom kit fduplicated 6 | #' 7 | #' @return a DEGContainer contains MSigDB data 8 | #' @export 9 | #' 10 | #' @examples 11 | #' msigdbGet(degcontainer) 12 | msigdbGet <- function(object) { 13 | 14 | ## 下载数据 15 | msigdbParam = msigdbParam(object) 16 | gene_sets = msigdbGetCore(msigdbParam = msigdbParam) 17 | 18 | ## 整理数据 19 | ## 根据设置,得到要获取的子集 20 | cat_param <- msigdbParam(object)[["category"]] 21 | if (is.null(cat_param)) { 22 | 23 | gs_cat = c("H",paste0("C",1:8)) 24 | 25 | } else { 26 | 27 | gs_cat = cat_param 28 | 29 | } 30 | 31 | ## 分割成子集,并做精简 32 | MSigDB_l <- lapply(gs_cat, function(x){ 33 | 34 | dat <- gene_sets[gene_sets$gs_cat==x,] 35 | ## 只留 gs_name 和 gene_symbol 并去重 36 | dat <- dat[,c("gs_name","gene_symbol")] 37 | # dat <- unique(dat) 38 | dat <- as.data.frame(dat[!fduplicated(dat),]) 39 | 40 | return(dat) 41 | 42 | }) 43 | ## 给子集命名 44 | names(MSigDB_l) <- gs_cat 45 | 46 | ## 前缀去除,只有 H 好换 47 | if ("H" %in% names(MSigDB_l)) { 48 | tmp <- MSigDB_l[["H"]] 49 | tmp$gs_name <- gsub("HALLMARK_","",tmp$gs_name) 50 | MSigDB_l[["H"]] <- tmp 51 | } 52 | 53 | ## 存储到对象 54 | msigdbData(object) <- MSigDB_l 55 | 56 | return(object) 57 | 58 | } 59 | 60 | #' @importFrom msigdbr msigdbr 61 | #' @export 62 | msigdbGetCore <- function(...,msigdbParam){ 63 | 64 | params <- list(...) 65 | msigdbParam <- modifyList(params, msigdbParam) 66 | msigdb_core <- suppressMessages(do.call("msigdbr", modifyList( 67 | list(), 68 | msigdbParam) 69 | )) 70 | 71 | return(msigdb_core) 72 | 73 | } 74 | 75 | #' GSE analysis of MSigDB data sets 76 | #' 77 | #' @param object a DEGContainer 78 | #' 79 | #' @return a DEGContainer 80 | #' @export 81 | #' 82 | #' @examples 83 | #' gseMSigDB(DEGContainer) 84 | gseMSigDB <- function(object) { 85 | 86 | msigdbGSEAparam <- msigdbGSEAparam(object) 87 | 88 | ## 获取GeneList 89 | test <- deg_here(object) 90 | ok <- names(test)[which(test == TRUE)] ## 取有效数据 91 | 92 | gseMSigDB_GeneSets = list() 93 | for (i in ok) { 94 | gseMSigDB_GeneSets[[i]] <- suppressWarnings(GSEA_GS(object,which = i,type = "SYMBOL")) 95 | } 96 | 97 | ## 对每个子集进行富集分析, 每个子集又可能存在多个geneList 做富集分析 98 | t2g_l <- msigdbData(object) 99 | res_l <- lapply(gseMSigDB_GeneSets, function(geneList){ 100 | 101 | gse_res_l <- lapply(seq_along(t2g_l), function(x){ 102 | 103 | enrichMSigDB_Core(geneList = geneList,TERM2GENE = t2g_l[[x]],fparam =msigdbGSEAparam,f= "GSEA") 104 | 105 | }) 106 | names(gse_res_l) <- names(t2g_l) 107 | return(gse_res_l) 108 | 109 | }) 110 | names(res_l) <- names(gseMSigDB_GeneSets) 111 | ## 结果存储 112 | msigdbGSEAresult(object) <- res_l 113 | return(object) 114 | 115 | } 116 | 117 | #' Hyper analysis of DEGContainer 118 | #' 119 | #' @param object a DEGContainer 120 | #' 121 | #' @return a DEGContainer 122 | #' @export 123 | #' 124 | #' @examples 125 | #' hyperMSigDB(DEGContainer) 126 | hyperMSigDB <- function(object){ 127 | 128 | msigdbHyperParam <- msigdbHyperParam(object) 129 | 130 | ## 获取GeneList 131 | test <- deg_here(object) 132 | ok <- names(test)[which(test == TRUE)] ## 取有效数据 133 | 134 | hyperMSigDB_GeneSets = list() 135 | for (i in ok) { 136 | hyperMSigDB_GeneSets[[i]] <- suppressWarnings(hyper_GS(object,which = i,type = "SYMBOL")) 137 | } 138 | 139 | ## 富集分析 140 | t2g_l <- msigdbData(object) 141 | 142 | hyperMSigDB_res <- lapply(seq_along(hyperMSigDB_GeneSets), function(x){ 143 | 144 | geneSet_list = hyperMSigDB_GeneSets[[x]] 145 | 146 | res <- lapply(seq_along(t2g_l), function(j){ 147 | 148 | hyperMSigDB_Resolve(geneSet_list = geneSet_list, 149 | TERM2GENE = t2g_l[[j]], 150 | msigdbHyperParam = msigdbHyperParam) 151 | 152 | }) 153 | 154 | names(res) <- names(t2g_l) 155 | 156 | ui_done("Enrich MSigDB {names(hyperMSigDB_GeneSets)[x]} analysis done") 157 | 158 | return(res) 159 | 160 | 161 | }) 162 | 163 | names(hyperMSigDB_res) <- names(hyperMSigDB_GeneSets) 164 | 165 | ## 结果存储 166 | msigdbHyperResult(object) <- hyperMSigDB_res 167 | return(object) 168 | 169 | } 170 | 171 | #' Hyper analysis for MSigDB 172 | #' 173 | #' @param ... more parameters for \code{\link[clusterProfiler]{enricher}} 174 | #' @param geneSet_list a gene set list 175 | #' @param msigdbHyperParam parameters for hyper 176 | #' 177 | #' @return a list of ernrichResult 178 | #' @export 179 | #' 180 | #' @examples 181 | #' hyperMSigDB_Resolve() 182 | hyperMSigDB_Resolve <- function(...,geneSet_list,msigdbHyperParam) { 183 | 184 | hyperRes <- lapply(seq_along(geneSet_list), function(x){ 185 | 186 | gene = geneSet_list[[x]] 187 | 188 | if (length(gene) == 0) { 189 | ui_oops("analysis skiped for not avaliable data.") 190 | } else { 191 | tryCatch( 192 | expr = { 193 | enrichMSigDB_Core(gene=gene,fparam = msigdbHyperParam,f = "enricher",...) 194 | }, 195 | error = function(e){ 196 | usethis::ui_oops("Something wrong occured. try again.") 197 | enrichMSigDB_Core(gene=gene,fparam = msigdbHyperParam,f = "enricher",...) 198 | }, 199 | finally = { 200 | usethis::ui_line("Enrich MSigDB {names(geneSet_list)[x]} analysis done") 201 | } 202 | ) 203 | } 204 | 205 | }) 206 | 207 | names(hyperRes) <- names(geneSet_list) 208 | 209 | return(hyperRes) 210 | 211 | } 212 | 213 | #' @importFrom clusterProfiler GSEA enricher 214 | #' @export 215 | enrichMSigDB_Core <- function(...,fparam,f){ 216 | 217 | params <- list(...) 218 | fparam <- modifyList(params, fparam) 219 | msigdb_core <- suppressMessages(do.call(f, modifyList( 220 | list(), 221 | fparam) 222 | )) 223 | 224 | return(msigdb_core) 225 | 226 | } 227 | 228 | #' GSVA analysis 229 | #' 230 | #' @param object a DEGContainer 231 | #' 232 | #' @importFrom GSEABase GeneSet GeneSetCollection EntrezIdentifier KEGGCollection 233 | #' @importFrom GSVA gsva 234 | #' 235 | #' @return 236 | #' @export 237 | #' 238 | #' @examples 239 | #' gsvaResolve(DEGContainer) 240 | gsvaResolve <- function(object) { 241 | 242 | # 重新提取数据 243 | msi_data_list <- msigdbData(object) 244 | 245 | # 将数据转换格式 246 | ids_list <- lapply(msi_data_list, function(x){ 247 | 248 | res <- split(x[,"gene_symbol"],x[,"gs_name"]) 249 | return(res) 250 | 251 | }) 252 | names(ids_list) <- names(msi_data_list) 253 | 254 | # 构建 GeneSetCollection 255 | GSC_list <- lapply(ids_list, function(x){ 256 | 257 | GeneSetCollection(mapply(function(geneIds, keggId) { 258 | GeneSet(geneIds, geneIdType=EntrezIdentifier(), 259 | collectionType=KEGGCollection(keggId), 260 | setName=keggId) 261 | }, x, names(x))) 262 | 263 | }) 264 | ## 运行gsva 265 | gsva_matrix <- as.matrix(matrixFiltered(object)) 266 | 267 | gsvaRes_list <- lapply(GSC_list, function(geneset){ 268 | 269 | es.max <- gsva(gsva_matrix, geneset, 270 | mx.diff=FALSE, 271 | verbose=FALSE, 272 | kcdf="Poisson", 273 | parallel.sz= parallel::detectCores()/2) 274 | 275 | return(es.max) 276 | 277 | }) 278 | 279 | gsvaDiff_list <- lapply(gsvaRes_list, function(es.max){ 280 | 281 | gsva_limma_resolve(es.max,group_list = groupInfo(object),case_group = caseGroup(object)) 282 | 283 | }) 284 | 285 | ## 存储结果 286 | msigdbGSVAresult(object) <- list( 287 | "GSVA_matrix" = gsvaRes_list, 288 | "GSVA_diff" = gsvaDiff_list 289 | ) 290 | 291 | return(object) 292 | 293 | } 294 | 295 | # 对GSVA 差异结果 296 | #' @importFrom limma lmFit makeContrasts contrasts.fit eBayes topTable 297 | gsva_limma_resolve <- function(gsva_data, group_list, case_group) { 298 | control_group = setdiff(group_list,case_group) 299 | design <- model.matrix(~0+factor(group_list)) 300 | colnames(design)=levels(factor(group_list)) 301 | rownames(design)=colnames(gsva_data) 302 | 303 | # dge <- DGEList(counts=gsva_data) 304 | # dge <- calcNormFactors(dge) 305 | # logCPM <- cpm(dge, log=TRUE, prior.count=3) 306 | 307 | # v <- voom(dge,design,plot=TRUE, normalize.method="quantile") 308 | fit <- lmFit(gsva_data, design) 309 | 310 | con=paste0(case_group,'-',control_group) 311 | 312 | cont.matrix=makeContrasts(contrasts=c(con),levels = design) 313 | fit2=contrasts.fit(fit,cont.matrix) 314 | fit2=eBayes(fit2) 315 | 316 | tempOutput = topTable(fit2, coef=con,adjust='BH', n=Inf) 317 | DEG_limma_voom = na.omit(tempOutput) 318 | 319 | return(DEG_limma_voom) 320 | 321 | } 322 | -------------------------------------------------------------------------------- /R/runALL.R: -------------------------------------------------------------------------------- 1 | #' run all workflow 2 | #' 3 | #' runALL include runCheck runDEG runHyper runGSEA runMSigDB 4 | #' 5 | #' @param object a DEGContainer 6 | #' @param dir a directory to store results 7 | #' @param top top for enrich result filter 8 | #' @param parallel use parallel in DESeq2 9 | #' @param GO logic, run GO in enrich step 10 | #' @param KEGG logic, run KEGG in enrich step 11 | #' 12 | #' @return a DEGContainer 13 | #' 14 | #' @export 15 | runALL <- function(object,dir = "output",top = 10,parallel = T,GO = FALSE,KEGG = TRUE) { 16 | 17 | tryCatch( 18 | expr = { 19 | runCheck(object = object,dir = dir) 20 | }, 21 | error = function(e){ 22 | usethis::ui_oops("Something wrong occured in Check. 23 | try again later by {ui_code('runCheck')}.") 24 | } 25 | ) 26 | 27 | tryCatch( 28 | expr = { 29 | object_g <- runDEG(obj = object,dir =dir, parallel = parallel) 30 | }, 31 | error = function(e){ 32 | usethis::ui_oops("Something wrong occured in DEG analysis. 33 | Can't continue....") 34 | } 35 | ) 36 | 37 | object_h <- tryCatch( 38 | expr = { 39 | runHyper(obj = object_g,dir = dir,top = top,GO = GO,KEGG = KEGG) 40 | }, 41 | error = function(e){ 42 | usethis::ui_oops("Something wrong occured in Hyper analysis. Skip it now. 43 | Try again later by {ui_code('runHyper')}") 44 | object_g 45 | } 46 | ) 47 | 48 | object_gs <- tryCatch( 49 | expr = { 50 | runGSEA(obj = object_h,dir = dir,top = top,GO = GO,KEGG= KEGG) 51 | }, 52 | error = function(e){ 53 | usethis::ui_oops("Something wrong occured in GSEA analysis. Skip it now. 54 | Try again later by {ui_code('runGSEA')}") 55 | object_h 56 | } 57 | ) 58 | 59 | object_va <- tryCatch( 60 | expr = { 61 | runMSigDB(obj = object_gs,dir = dir,top = top) 62 | }, 63 | error = function(e){ 64 | usethis::ui_oops("Something wrong occured in runMSigDB analysis. Skip it now. 65 | Try again later by {ui_code('runMSigDB')}") 66 | object_gs 67 | } 68 | ) 69 | 70 | return(object_va) 71 | 72 | } 73 | -------------------------------------------------------------------------------- /R/runCheck.R: -------------------------------------------------------------------------------- 1 | #' Check you data by PCA and Heatmaps 2 | #' 3 | #' A previous check function for overview the data sets. 4 | #' 5 | #' @param object a DEGContainer contains at least dataInfo 6 | #' @param dir a directory to store results 7 | #' @param prefix a prefix of file names in this step 8 | #' @param palette a color palette for plots 9 | #' 10 | #' @importFrom usethis ui_done ui_path ui_info 11 | #' @importFrom glue glue 12 | #' @importFrom edgeR cpm 13 | #' @importFrom fs dir_exists dir_create 14 | #' 15 | #' @return 16 | #' @export 17 | #' 18 | #' @examples 19 | #' runCheck(object, tempdir()) 20 | runCheck <- function(object, 21 | dir = ".", 22 | prefix = "1-run_check", 23 | palette = RColorBrewer::brewer.pal(3,"Set2")[1:2]) { 24 | 25 | if (!fs::dir_exists(dir)) { 26 | fs::dir_create(dir) 27 | } 28 | 29 | exprSet= matrixFiltered(object) 30 | group_list = groupInfo(object) 31 | 32 | if(dataType(object) == "Counts") { 33 | 34 | ui_info("Your Counts will be Convert to CPM and make a check!") 35 | dat=cpm(exprSet, prior.count = 2, log = TRUE) 36 | # dat = log2(cpm(exprSet)+1) 37 | 38 | box_check(data = dat,group_list,dir = dir,prefix = prefix,palette = palette,y = "log2(cpm(count)+1)") 39 | ui_done(glue("Box checking have done, a plot was store in {ui_path(dir)}.")) 40 | suppressMessages(density_check(data = dat,group_list,dir = dir,prefix = prefix,palette = palette,y = "log2(cpm(count)+1)")) 41 | ui_done(glue("Density checking have done, a plot was store in {ui_path(dir)}.")) 42 | 43 | } else if (dataType(object) == "Array") { 44 | 45 | ui_info("Your Array will be make a check!") 46 | dat = as.matrix(exprSet) 47 | 48 | box_check(data = dat,group_list,dir = dir,prefix = prefix,palette = palette,y = "expression value") 49 | ui_done(glue("Box checking have done, a plot was store in {ui_path(dir)}.")) 50 | suppressMessages(density_check(data = dat,group_list,dir = dir,prefix = prefix,palette = palette,y = "expression value")) 51 | ui_done(glue("Density checking have done, a plot was store in {ui_path(dir)}.")) 52 | 53 | } 54 | 55 | if(species(object) == "Human"){ 56 | HKG_check(data = dat,group_list,dir = dir,prefix = prefix,palette = palette) 57 | ui_done(glue("HKG checking have done, a plot was store in {ui_path(dir)}.")) 58 | } 59 | 60 | pca_check(data = dat,group_list,dir = dir,prefix = prefix,palette = palette) 61 | ui_done(glue("PCA checking have done, a plot was store in {ui_path(dir)}.")) 62 | corall_check(data = dat,group_list,dir = dir,prefix = prefix,palette = palette) 63 | ui_done(glue("Correlation checking have done, a plot was store in {ui_path(dir)}.")) 64 | cor500_check(data = dat,group_list,dir = dir,prefix = prefix,palette = palette) 65 | ui_done(glue("Correlation to top 500 genes checking have done, a plot was store in {ui_path(dir)}.")) 66 | top1000_check(data = dat,group_list,dir = dir,prefix = prefix,palette = palette) 67 | ui_done(glue("Standard Deviation top 1000 genes checking have done, a plot was store in {ui_path(dir)}.")) 68 | 69 | } 70 | 71 | #' PCA QC check 72 | #' 73 | #' check data quality by PCA plot 74 | #' 75 | #' @param data a cpm data frame of rows in genes and columns in samples 76 | #' @param group a list ordered by samples in data 77 | #' @param dir a directory to store results 78 | #' @param prefix a prefix of file names in this step 79 | #' @param palette a color palette for plots 80 | #' 81 | #' @importFrom glue glue 82 | #' 83 | #' @return a figure of PCA 84 | #' @export 85 | #' 86 | #' @examples 87 | #' pca_check(data, group) 88 | pca_check <- function(data, group, dir = ".", prefix = "1-run_check", palette = RColorBrewer::brewer.pal(3,"Set2")[1:2]) { 89 | filename = glue('{dir}/{prefix}_all_samples_PCA_by_type.pdf') 90 | exprPCA(expr = data, group_list = group, 91 | palette = palette, 92 | filename = filename, main = "all samples - PCA", 93 | width=4, height = 4) 94 | } 95 | 96 | #' Correlation of all samples and all genes 97 | #' 98 | #' Check data quality by calculating correlation of all samples 99 | #' 100 | #' @param data a cpm data frame of rows in genes and columns in samples 101 | #' @param group a list ordered by samples in data 102 | #' @param dir a directory to store results 103 | #' @param prefix a prefix of file names in this step 104 | #' @param palette a color palette for plots 105 | #' 106 | #' @importFrom glue glue 107 | #' 108 | #' @return a Heatmap shows correlation of all samples 109 | #' @export 110 | #' 111 | #' @examples 112 | #' corall_check(data, group) 113 | corall_check <- function(data, group, dir = ".", prefix = "1-run_check",palette = RColorBrewer::brewer.pal(3,"Set2")[1:2]) { 114 | filename = glue('{dir}/{prefix}_cor_all.pdf') 115 | exprCorHeatmap(expr = data,group_list = group,palette = palette,filename = filename,main = "Correlation by all genes") 116 | } 117 | 118 | #' Correlation of all samples and top 500 genes 119 | #' 120 | #' Check data quality by calculating correlation of all samples but top 500 genes 121 | #' 122 | #' @param counts_data a counts data frame of rows in genes and columns in samples 123 | #' @param group a list ordered by samples in data 124 | #' @param dir a directory to store results 125 | #' @param prefix a prefix of file names in this step 126 | #' @param palette a color palette for plots 127 | #' 128 | #' @importFrom glue glue 129 | #' 130 | #' @return a Heatmap shows correlation of all samples to 500 genes 131 | #' @export 132 | #' 133 | #' @examples 134 | #' cor500_check(counts_input, group) 135 | cor500_check <- function(data, group, dir = ".", prefix = "1-run_check",palette = RColorBrewer::brewer.pal(3,"Set2")[1:2]) { 136 | filename = glue('{dir}/{prefix}_cor_top500.pdf') 137 | exprCorHeatmap(expr = data,group_list = group,palette = palette,top=500,filename = filename,main = "Correlation by 500 genes") 138 | } 139 | 140 | #' Heatmap of all samples and Top1000 genes 141 | #' 142 | #' Check data quality by plotting heatmap of top 1000 genes 143 | #' 144 | #' @param data a cpm data frame of rows in genes and columns in samples 145 | #' @param group a list ordered by samples in data 146 | #' @param dir a directory to store results 147 | #' @param prefix a prefix of file names in this step 148 | #' @param palette a color palette for plots 149 | #' 150 | #' @importFrom glue glue 151 | #' @importFrom pheatmap pheatmap 152 | #' @importFrom stats sd 153 | #' @importFrom utils tail 154 | #' 155 | #' @return a Heatmap shows top100 genes of all samples 156 | #' @export 157 | #' 158 | #' @examples 159 | #' top1000_check(data, group) 160 | top1000_check <- function(data, group, dir = ".", prefix = "1-run_check",palette = RColorBrewer::brewer.pal(3,"Set2")[1:2]) { 161 | filename = glue('{dir}/{prefix}_heatmap_top1000_sd.pdf') 162 | exprTopHeatmap(expr = data,group_list = group,filename = filename,palette = palette,top = 1000,main = "SD Top 1000 genes") 163 | } 164 | 165 | 166 | #' Boxplot of expression matrix 167 | #' 168 | #' Check data by box plot 169 | #' 170 | #' @param data a cpm data frame of rows in genes and columns in samples 171 | #' @param group a list ordered by samples in data 172 | #' @param dir a directory to store results 173 | #' @param prefix a prefix of file names in this step 174 | #' @param palette a color palette for plots 175 | #' @param ... more parameters in \code{\link{exprBox}} 176 | #' 177 | #' @return a ridges plot file 178 | #' @export 179 | #' 180 | #' @examples 181 | #' density_check(data,group) 182 | box_check <- function(data, group, dir = ".", prefix = "1-run_check",palette = RColorBrewer::brewer.pal(3,"Set2")[1:2],...) { 183 | filename = glue('{dir}/{prefix}_boxplot.pdf') 184 | exprBox(expr = data,group_list = group,filename = filename,palette = palette,main = "Boxplot of gene expression",...) 185 | } 186 | #' Density of expression matrix 187 | #' 188 | #' Check data density by ridges plot 189 | #' 190 | #' @param data a cpm data frame of rows in genes and columns in samples 191 | #' @param group a list ordered by samples in data 192 | #' @param dir a directory to store results 193 | #' @param prefix a prefix of file names in this step 194 | #' @param palette a color palette for plots 195 | #' @param ... more parameters in \code{\link{exprRidges}} 196 | #' 197 | #' @return a ridges plot file 198 | #' @export 199 | #' 200 | #' @examples 201 | #' density_check(data,group) 202 | density_check <- function(data, group, dir = ".", prefix = "1-run_check",palette = RColorBrewer::brewer.pal(3,"Set2")[1:2],...) { 203 | filename = glue('{dir}/{prefix}_density.pdf') 204 | exprRidges(expr = data,group_list = group,filename = filename,palette = palette,main = "Density of gene expression",...) 205 | } 206 | 207 | #' Human housekeeping genes expression 208 | #' 209 | #' Check Human housekeeping genes expression 210 | #' 211 | #' @param data a cpm data frame of rows in genes and columns in samples 212 | #' @param group a list ordered by samples in data 213 | #' @param dir a directory to store results 214 | #' @param prefix a prefix of file names in this step 215 | #' @param palette a color palette for plots 216 | #' 217 | #' @return a heatmap plot file 218 | #' @export 219 | #' 220 | #' @examples 221 | #' HKG_check(data,group) 222 | HKG_check <- function(data, group, dir = ".", prefix = "1-run_check",palette = RColorBrewer::brewer.pal(3,"Set2")[1:2]) { 223 | filename = glue('{dir}/{prefix}_HKG.pdf') 224 | exprHKGheatmap(expr = data,group_list = group,filename = filename,palette = palette,main = "Human housekeeping genes expression") 225 | } 226 | -------------------------------------------------------------------------------- /R/runDEG.R: -------------------------------------------------------------------------------- 1 | #' run DEG analysis 2 | #' 3 | #' run DEG analysis and summary results 4 | #' 5 | #' @param obj a DEGContainer 6 | #' @param dir a directory to store results 7 | #' @param prefix a prefix of file names in this step 8 | #' @param parallel use parallel in DESeq2 9 | #' @param qc qc in DESeq2 10 | #' @param PointVolcanoParam for volcano plot 11 | #' 12 | #' @return 13 | #' @export 14 | #' 15 | #' @examples 16 | #' runDEG(DEGContainer) 17 | setGeneric(name="runDEG", def=function(obj, dir = ".", prefix = "2-runDEG", 18 | parallel = TRUE,qc=TRUE, 19 | PointVolcanoParam = list(gene = 10,light = NULL, 20 | light_color = "#24ac56", 21 | light_label_color = "#24ac56", 22 | expend = c(0.12, 0.12))) standardGeneric("runDEG")) 23 | 24 | setMethod(f="runDEG", signature="DEGContainer", definition=function(obj, dir = ".", prefix = "2-runDEG", 25 | parallel = TRUE,qc=TRUE, 26 | PointVolcanoParam = list(gene = 10,light = NULL, 27 | light_color = "#24ac56", 28 | light_label_color = "#24ac56", 29 | expend = c(0.12, 0.12))) { 30 | 31 | if (!fs::dir_exists(dir)) { 32 | fs::dir_create(dir) 33 | } 34 | 35 | ## DEG resolve of limma edgeR DESeq2 36 | if (dataType(obj) == "Array") { 37 | 38 | if (all(deg_here(obj)[c(1,2,4)])) { 39 | usethis::ui_info("DEG analysis seems done. ignored") 40 | } else { 41 | obj <- degResolveArray(obj = obj, dir = dir, prefix = prefix) 42 | } 43 | 44 | } else { 45 | 46 | if (all(deg_here(obj))) { 47 | usethis::ui_info("DEG analysis seems done. ignored") 48 | } else { 49 | obj <- degResolve(obj = obj, dir = dir, prefix = prefix,parallel = parallel, qc =qc) 50 | } 51 | 52 | 53 | } 54 | 55 | ## group DEG Results 56 | obj <- degGroup(obj = obj) 57 | 58 | tryCatch( 59 | expr = { 60 | degSummary(obj = obj, dir = dir,prefix = prefix,PointVolcanoParam = PointVolcanoParam) 61 | }, 62 | error = function(e){ 63 | usethis::ui_oops("Something wrong occured in DEG Summary. try again later by {ui_code('degSummary')}.") 64 | }, 65 | finally = { 66 | usethis::ui_line("DEG analysis step done") 67 | } 68 | ) 69 | 70 | 71 | 72 | return(obj) 73 | 74 | }) 75 | -------------------------------------------------------------------------------- /R/runGSEA.R: -------------------------------------------------------------------------------- 1 | #' runGSEA Module 2 | #' 3 | #' runGSEA Module control GO and KEGG 4 | #' 5 | #' @param obj a DEGContainer 6 | #' @param dir a directory to store results 7 | #' @param prefix a prefix of file names in this step 8 | #' @param top top rows of up and down 9 | #' @param GO run GO 10 | #' @param KEGG run KEGG 11 | #' 12 | #' @import enrichplot 13 | #' @import ggplot2 14 | #' @importFrom DOSE theme_dose 15 | #' @export 16 | #' 17 | #' @return 18 | #' @export 19 | #' 20 | #' @examples 21 | #' runGSEA(DEGContainer) 22 | setGeneric(name="runGSEA", def=function(obj, dir = ".", prefix = "4-runGSEA",top =10, GO = FALSE, KEGG = TRUE) standardGeneric("runGSEA")) 23 | 24 | setMethod(f="runGSEA", signature="DEGContainer", definition=function(obj, dir = ".", prefix = "4-runGSEA",top = 10, GO = FALSE, KEGG = TRUE) { 25 | 26 | if (!fs::dir_exists(dir)) { 27 | fs::dir_create(dir) 28 | } 29 | 30 | ## hyper resolve of limma edgeR DESeq2 31 | if (length(gseRes(obj)) == 0) { 32 | obj <- gseResolve(obj = obj, GO = GO, KEGG = KEGG) 33 | } 34 | 35 | tryCatch( 36 | expr = { 37 | gseSummary(obj = obj, dir = dir, prefix = prefix,top = top) 38 | }, 39 | error = function(e){ 40 | usethis::ui_oops("Something wrong occured in GSEA Summary. try again later by {ui_code('gseSummary')}.") 41 | }, 42 | finally = { 43 | usethis::ui_line("GSEA analysis step done") 44 | } 45 | ) 46 | 47 | return(obj) 48 | 49 | }) 50 | -------------------------------------------------------------------------------- /R/runHyper.R: -------------------------------------------------------------------------------- 1 | #' runHyper 2 | #' 3 | #' @param obj a DEGContainer 4 | #' @param dir a directory to store results 5 | #' @param prefix a prefix of file names in this step 6 | #' @param top top for enrich result filter 7 | #' @param GO logic, run GO in enrich step 8 | #' @param KEGG logic, run KEGG in enrich step 9 | #' 10 | #' @import enrichplot 11 | #' @export 12 | #' 13 | #' @return a DEGContainer 14 | #' @export 15 | #' 16 | #' @examples 17 | #' runHyper(DEGContainer) 18 | setGeneric(name="runHyper", def=function(obj, dir = ".", prefix = "3-runHyper",top = 10,GO = FALSE, KEGG = TRUE) standardGeneric("runHyper")) 19 | 20 | setMethod(f="runHyper", signature="DEGContainer", definition=function(obj, dir = ".", prefix = "3-runHyper",top = 10,GO = FALSE, KEGG = TRUE) { 21 | 22 | if (!fs::dir_exists(dir)) { 23 | fs::dir_create(dir) 24 | } 25 | 26 | ## hyper resolve of limma edgeR DESeq2 27 | if (length(hyperRes(obj)) == 0) { 28 | obj <- hyperResolve(obj = obj,GO = GO,KEGG=KEGG) 29 | } 30 | 31 | tryCatch( 32 | expr = { 33 | hyperSummary(obj = obj, dir = dir, prefix = prefix,top = top) 34 | }, 35 | error = function(e){ 36 | usethis::ui_oops("Something wrong occured in Hyper Summary. try again later by {ui_code('hyperSummary')}.") 37 | }, 38 | finally = { 39 | usethis::ui_line("Hyper analysis step done") 40 | } 41 | ) 42 | 43 | return(obj) 44 | 45 | }) 46 | -------------------------------------------------------------------------------- /R/runMSigDB.R: -------------------------------------------------------------------------------- 1 | #' run MSigDB module 2 | #' 3 | #' @param obj a DEGContainer after MSigDB analysis 4 | #' @param dir a directory to store results 5 | #' @param prefix a prefix of file names in this step 6 | #' @param top top 7 | #' 8 | #' @return 9 | #' @export 10 | #' 11 | #' @examples 12 | #' runMSigDB(data_gse) 13 | setGeneric(name="runMSigDB", def=function(obj, dir = ".", prefix = "5-runMSigDB", top =10) standardGeneric("runMSigDB")) 14 | setMethod(f="runMSigDB", signature="DEGContainer", definition=function(obj, dir = ".", prefix = "5-runMSigDB",top = 10) { 15 | 16 | if (!fs::dir_exists(dir)) { 17 | fs::dir_create(dir) 18 | } 19 | 20 | if (!is.null(msigdbParam(obj))) { 21 | 22 | ## Download data 23 | if (length(msigdbData(obj)) == 0) { 24 | obj <- msigdbGet(obj) 25 | } 26 | 27 | ## Do gse 28 | if (length(msigdbGSEAresult(obj)) == 0) { 29 | obj <- gseMSigDB(obj) 30 | } 31 | 32 | ## Do Hyper 33 | if (length(msigdbGSEAresult(obj)) == 0) { 34 | obj <- hyperMSigDB(obj) 35 | } 36 | 37 | ## gsva 38 | if (length(msigdbGSVAresult(obj)) == 0) { 39 | obj <- gsvaResolve(obj) 40 | } 41 | 42 | obj@MSigDB <- degGroup(obj@MSigDB) 43 | 44 | tryCatch( 45 | expr = { 46 | MSigDBSummary(obj, dir = dir, prefix = prefix,top =top) 47 | }, 48 | error = function(e){ 49 | usethis::ui_oops("Something wrong occured in Hyper Summary. try again later by {ui_code('MSigDBSummary')}.") 50 | }, 51 | finally = { 52 | usethis::ui_line("Hyper analysis step done") 53 | } 54 | ) 55 | 56 | } else { 57 | ui_info("MSigDB step skiped.") 58 | } 59 | 60 | return(obj) 61 | 62 | }) 63 | -------------------------------------------------------------------------------- /R/utils-go.R: -------------------------------------------------------------------------------- 1 | ##' Gene Set Enrichment Analysis of Gene Ontology 2 | ##' 3 | ##' 4 | ##' @title gseGO2 5 | ##' @param geneList order ranked geneList 6 | ##' @param ont one of "BP", "MF", and "CC" subontologies, or "ALL" for all three. 7 | ##' @param keyType keytype of gene 8 | ##' @param exponent weight of each step 9 | ##' @param minGSSize minimal size of each geneSet for analyzing 10 | ##' @param maxGSSize maximal size of genes annotated for testing 11 | ##' @param eps This parameter sets the boundary for calculating the p value. 12 | ##' @param pvalueCutoff pvalue Cutoff 13 | ##' @param pAdjustMethod pvalue adjustment method 14 | ##' @param verbose print message or not 15 | ##' @param seed logical 16 | ##' @param by one of 'fgsea' or 'DOSE' 17 | ##' @param ... other parameter 18 | ##' @importClassesFrom DOSE gseaResult 19 | ##' @export 20 | ##' @return gseaResult object 21 | gseGO2 <- function(geneList, 22 | ont = "ALL", 23 | TERM2GENE, 24 | TERM2NAME = NA, 25 | organism = "UNKNOW", 26 | keyType = "SYMBOL", 27 | exponent = 1, 28 | minGSSize = 10, 29 | maxGSSize = 500, 30 | eps = 1e-10, 31 | pvalueCutoff = 0.05, 32 | pAdjustMethod = "BH", 33 | verbose = TRUE, 34 | seed = FALSE, 35 | by = 'fgsea', 36 | ...) { 37 | 38 | ont %<>% toupper 39 | ont <- match.arg(ont, c("BP", "MF", "CC", "ALL")) 40 | 41 | GO_DATA <- get_GO_data2(TERM2GENE, TERM2NAME, keyType, ont, organism) 42 | 43 | res <- DOSE:::GSEA_internal(geneList = geneList, 44 | exponent = exponent, 45 | minGSSize = minGSSize, 46 | maxGSSize = maxGSSize, 47 | eps = eps, 48 | pvalueCutoff = pvalueCutoff, 49 | pAdjustMethod = pAdjustMethod, 50 | verbose = verbose, 51 | USER_DATA = GO_DATA, 52 | seed = seed, 53 | by = by, 54 | ...) 55 | 56 | 57 | 58 | if (is.null(res)) 59 | return(res) 60 | 61 | res@organism <- organism 62 | res@setType <- ont 63 | res@keytype <- keyType 64 | 65 | if (ont == "ALL") { 66 | res <- clusterProfiler:::add_GO_Ontology(res, GO_DATA) 67 | } 68 | return(res) 69 | } 70 | 71 | #' GO Enrichment Analysis of a gene set. 72 | #' 73 | #' Given a vector of genes, this function will return the enrichment GO 74 | #' categories after FDR control. \code{\link[clusterProfiler]{enrichGO}} only support OrgDb and 75 | #' \code{\link[clusterProfiler]{enricher}} is too simple for GO. 76 | #' In this case, a modified version of enrichGO here 77 | #' 78 | #' @param gene a vector of entrez gene id. 79 | #' @param TERM2GENE user input annotation of TERM TO GENE mapping, a data.frame of 2 column with term and gene 80 | #' @param TERM2NAME user input of TERM TO NAME mapping, a data.frame of 2 column with term and name 81 | #' @param keyType keytype of input gene 82 | #' @param ont One of "BP", "MF", and "CC" subontologies, or "ALL" for all three. 83 | #' @param pvalueCutoff adjusted pvalue cutoff on enrichment tests to report 84 | #' @param pAdjustMethod one of "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none" 85 | #' @param universe background genes. If missing, the all genes listed in the database (eg TERM2GENE table) will be used as background. 86 | #' @param qvalueCutoff qvalue cutoff on enrichment tests to report as significant. Tests must pass i) \code{pvalueCutoff} on unadjusted pvalues, ii) \code{pvalueCutoff} on adjusted pvalues and iii) \code{qvalueCutoff} on qvalues to be reported. 87 | #' @param minGSSize minimal size of genes annotated by Ontology term for testing. 88 | #' @param maxGSSize maximal size of genes annotated for testing 89 | #' @param pool If ont='ALL', whether pool 3 GO sub-ontologies 90 | #' @return An \code{enrichResult} instance. 91 | #' @importClassesFrom DOSE enrichResult 92 | #' @importFrom DOSE setReadable 93 | #' @keywords manip 94 | #' @export 95 | #' @examples 96 | #' \dontrun{ 97 | #' enrichGO2(gene,TERM2GENE,TERM2NAME) 98 | #' } 99 | enrichGO2 <- function(gene, 100 | TERM2GENE, 101 | TERM2NAME = NA, 102 | organism = "UNKNOW", 103 | keyType = "SYMBOL", 104 | ont = "ALL", 105 | pvalueCutoff=0.05, 106 | pAdjustMethod="BH", 107 | universe, 108 | qvalueCutoff = 0.2, 109 | minGSSize = 10, 110 | maxGSSize = 500, 111 | pool=FALSE) { 112 | 113 | ont %<>% toupper 114 | ont <- match.arg(ont, c("BP", "MF", "CC", "ALL")) 115 | 116 | GO_DATA <- get_GO_data2(TERM2GENE, TERM2NAME, keyType, ont, organism) 117 | 118 | # GO_DATA <- get_GO_data(OrgDb, ont, keyType) 119 | 120 | if (missing(universe)) 121 | universe <- NULL 122 | 123 | if (ont == "ALL" && !pool) { 124 | lres <- lapply(c("BP", "CC", "MF"), function(ont) 125 | suppressMessages(enrichGO2(gene, TERM2GENE,TERM2NAME,organism, keyType, ont, 126 | pvalueCutoff, pAdjustMethod, universe, 127 | qvalueCutoff, minGSSize, maxGSSize 128 | )) 129 | ) 130 | 131 | lres <- lres[!vapply(lres, is.null, logical(1))] 132 | if (length(lres) == 0) 133 | return(NULL) 134 | 135 | df <- do.call('rbind', lapply(lres, as.data.frame)) 136 | geneSets <- lres[[1]]@geneSets 137 | if (length(lres) > 1) { 138 | for (i in 2:length(lres)) { 139 | geneSets <- append(geneSets, lres[[i]]@geneSets) 140 | } 141 | } 142 | res <- lres[[1]] 143 | res@result <- df 144 | res@geneSets <- geneSets 145 | } else { 146 | res <- DOSE:::enricher_internal(gene, 147 | pvalueCutoff=pvalueCutoff, 148 | pAdjustMethod=pAdjustMethod, 149 | universe = universe, 150 | qvalueCutoff = qvalueCutoff, 151 | minGSSize = minGSSize, 152 | maxGSSize = maxGSSize, 153 | USER_DATA = GO_DATA 154 | ) 155 | 156 | if (is.null(res)) 157 | return(res) 158 | } 159 | 160 | res@keytype <- keyType 161 | res@organism <- organism 162 | # if(readable) { 163 | # res <- clusterProfiler::setReadable(res, OrgDb) 164 | # } 165 | res@ontology <- ont 166 | 167 | if (ont == "ALL") { 168 | res <- clusterProfiler:::add_GO_Ontology(res, GO_DATA) 169 | } 170 | return(res) 171 | 172 | } 173 | 174 | get_GO_data2 <- function(TERM2GENE, TERM2NAME = NA, keyType, ont, organism = "UNKNOW") { 175 | 176 | GO_Env <- clusterProfiler:::get_GO_Env() 177 | use_cached <- FALSE 178 | keytype = keyType 179 | 180 | ont2 <- NULL 181 | if (exists("ont", envir = GO_Env, inherits = FALSE)) 182 | ont2 <- get("ont", envir = GO_Env) 183 | 184 | if (exists("organism", envir=GO_Env, inherits=FALSE) && 185 | exists("keytype", envir=GO_Env, inherits=FALSE) && 186 | !is.null(ont2)) { 187 | 188 | org <- get("organism", envir=GO_Env) 189 | kt <- get("keytype", envir=GO_Env) 190 | 191 | if (org == organism && 192 | keytype == kt && 193 | (ont == ont2 || ont2 == "ALL") && 194 | exists("goAnno", envir=GO_Env, inherits=FALSE)) { 195 | ## https://github.com/GuangchuangYu/clusterProfiler/issues/182 196 | ## && exists("GO2TERM", envir=GO_Env, inherits=FALSE)){ 197 | 198 | use_cached <- TRUE 199 | } 200 | } 201 | 202 | if (use_cached) { 203 | goAnno <- get("goAnno", envir=GO_Env) 204 | if (!is.null(ont2) && ont2 != ont) { ## ont2 == "ALL" 205 | goAnno <- goAnno[goAnno$ONTOLOGYALL == ont,] 206 | } 207 | } else { 208 | 209 | goOnt.df <- clusterProfiler::go2ont(as.character(TERM2GENE[,1])) 210 | goterms <- goOnt.df[,2] 211 | names(goterms) <- goOnt.df[,1] 212 | 213 | if (ont != "ALL") { 214 | goterms <- goterms[goterms == ont] 215 | } 216 | 217 | goAnno <- TERM2GENE[,c(2,1)] 218 | 219 | colnames(goAnno) <- c(keytype, "GOALL") 220 | goAnno <- unique(goAnno[!is.na(goAnno[,1]), ]) 221 | goAnno$ONTOLOGYALL <- goterms[goAnno$GOALL] 222 | 223 | assign("goAnno", goAnno, envir=GO_Env) 224 | assign("keytype", keytype, envir=GO_Env) 225 | assign("ont", ont, envir = GO_Env) 226 | assign("organism", organism, envir=GO_Env) 227 | } 228 | 229 | GO2GENE <- unique(goAnno[, c(2,1)]) 230 | 231 | GO_DATA <- DOSE:::build_Anno(GO2GENE, TERM2NAME) 232 | 233 | goOnt.df <- goAnno[, c("GOALL", "ONTOLOGYALL")] %>% unique 234 | 235 | if (!is.null(ont2) && ont2 == "ALL") { 236 | return(GO_DATA) 237 | } 238 | 239 | goOnt <- goOnt.df[,2] 240 | names(goOnt) <- goOnt.df[,1] 241 | assign("GO2ONT", goOnt, envir=GO_DATA) 242 | 243 | return(GO_DATA) 244 | } 245 | 246 | -------------------------------------------------------------------------------- /R/utils-pipe.R: -------------------------------------------------------------------------------- 1 | #' Pipe operator 2 | #' 3 | #' See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details. 4 | #' 5 | #' @name %>% 6 | #' @rdname pipe 7 | #' @keywords internal 8 | #' @export 9 | #' @importFrom magrittr %>% %<>% 10 | #' @usage lhs \%>\% rhs 11 | #' @param lhs A value or the magrittr placeholder. 12 | #' @param rhs A function call using the magrittr semantics. 13 | #' @return The result of calling `rhs(lhs)`. 14 | NULL 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # RNAseqStat2 3 | 4 | 5 | 6 | 7 | The goal of RNAseqStat2 is to do DEG analysis 8 | 9 | ## Installation 10 | 11 | You can install the development version of RNAseqStat2 from [GitHub](https://github.com/) with: 12 | 13 | ``` r 14 | # install.packages("devtools") 15 | devtools::install_github("xiayh17/RNAseqStat2") 16 | ``` 17 | 18 | ## Example 19 | 20 | This is a basic example which shows you how to solve a common problem: 21 | 22 | ``` r 23 | library(RNAseqStat2) 24 | library(airway) 25 | 26 | data("airway") 27 | 28 | row_counts <- as.data.frame(assay(airway)) 29 | 30 | group_list <- as.character(colData(airway)$dex) 31 | 32 | data_i <- Create_DEGContainer(species = "Human", 33 | dataType = "Counts", 34 | idType = "ENSEMBL", 35 | expMatrix = row_counts, 36 | groupInfo = group_list, 37 | caseGroup = "trt") 38 | 39 | # run all in one line 40 | data_o <- runALL(object = data_i,dir = "output_test") 41 | ``` 42 | 43 | 更多参考文档 44 | https://www.yuque.com/xiayonghe/rnaseqstat2 45 | -------------------------------------------------------------------------------- /RNAseqStat2.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 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageRoxygenize: rd,collate,namespace 22 | -------------------------------------------------------------------------------- /dev/Msigdb.R: -------------------------------------------------------------------------------- 1 | library(msigdbr) 2 | library(GSEABase) 3 | library(GSVA) 4 | msigdbr::msigdbr_species() 5 | 6 | c("Homo sapiens","Mus musculus") 7 | 8 | ## 一次下载全部会很大 4263110行 9 | c1_gene_sets = msigdbr(species = "Homo sapiens",category = "C8") 10 | 11 | # 查看各个子集的数量 12 | table(all_gene_sets$gs_cat) 13 | 14 | # 提取一个子集分析 15 | H_gene_sets = all_gene_sets[all_gene_sets$gs_cat=='H',] 16 | 17 | # 只保留基因名和通路并去重 18 | H_gene_sets=H_gene_sets[,3:4] 19 | H_gene_sets=unique(H_gene_sets) 20 | 21 | # 做GSEA 22 | geneList <- GSEA_GS(data_g,"limma",type = "SYMBOL") 23 | 24 | gsea_res_limma <- GSEA(geneList = geneList,TERM2GENE = H_gene_sets) 25 | 26 | is.null(gsea_res_limma) 27 | 28 | # 29 | 30 | # 做GSVA 31 | # 需要转化功能基因表为list 32 | H_gene_sets_list = split(H_gene_sets$gene_symbol,H_gene_sets$gs_name) 33 | 34 | # 构建genecollection 35 | geneset <- GeneSetCollection(mapply(function(geneIds, keggId) { 36 | GeneSet(geneIds, geneIdType=EntrezIdentifier(), 37 | collectionType=KEGGCollection(keggId), 38 | setName=keggId) 39 | }, H_gene_sets_list , names(H_gene_sets_list))) 40 | geneset 41 | # gsva 是针对矩阵 ,需要的是 geneset这样的 GeneSetCollection对象 42 | # 使用原始count 矩阵需要添加kcdf="Poisson" 43 | # 或者使用logcpm 44 | es.max <- gsva( as.matrix(matrixFiltered(data_g)) , geneset, 45 | mx.diff=FALSE, 46 | verbose=FALSE, 47 | kcdf="Poisson", 48 | parallel.sz= 2) 49 | 50 | # 对GSVA 差异结果 51 | gsva_limma_resolve <- function(gsva_data, group_list, case_group) { 52 | control_group = setdiff(group_list,case_group) 53 | design <- model.matrix(~0+factor(group_list)) 54 | colnames(design)=levels(factor(group_list)) 55 | rownames(design)=colnames(gsva_data) 56 | 57 | # dge <- DGEList(counts=gsva_data) 58 | # dge <- calcNormFactors(dge) 59 | # logCPM <- cpm(dge, log=TRUE, prior.count=3) 60 | 61 | # v <- voom(dge,design,plot=TRUE, normalize.method="quantile") 62 | fit <- lmFit(gsva_data, design) 63 | 64 | con=paste0(case_group,'-',control_group) 65 | 66 | cont.matrix=makeContrasts(contrasts=c(con),levels = design) 67 | fit2=contrasts.fit(fit,cont.matrix) 68 | fit2=eBayes(fit2) 69 | 70 | tempOutput = topTable(fit2, ,coef=con,adjust='BH', n=Inf) 71 | DEG_limma_voom = na.omit(tempOutput) 72 | 73 | return(DEG_limma_voom) 74 | 75 | } 76 | 77 | t <- gsva_limma_resolve(es.max,group_list = groupInfo(data_g),case_group = caseGroup(data_g)) 78 | 79 | pathway <- gsub("HALLMARK_", "",row.names(t)) 80 | df <- data.frame(ID = pathway, score = t$t) 81 | 82 | -------------------------------------------------------------------------------- /dev/RNAseqStat2.xmind: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiayh17/RNAseqStat2/4ae8e3a7a3062c3be0ecfea7811320c7f17bfc17/dev/RNAseqStat2.xmind -------------------------------------------------------------------------------- /dev/TestWorkflowArray.R: -------------------------------------------------------------------------------- 1 | library(AnnoProbe) 2 | suppressPackageStartupMessages(library(GEOquery)) 3 | 4 | ## 使用AnnoProbe 获取数据 5 | gset=AnnoProbe::geoChina('GSE1009') 6 | 7 | # check the ExpressionSet 8 | eSet=gset[[1]] 9 | # extract the expression matrix and phenotype data 10 | probes_expr <- exprs(eSet);dim(probes_expr) 11 | head(probes_expr[,1:4]) 12 | boxplot(probes_expr,las=2) 13 | probes_expr=limma::normalizeBetweenArrays(probes_expr) 14 | boxplot(probes_expr,las=2) 15 | ## pheno info 16 | phenoDat <- pData(eSet) 17 | head(phenoDat[,1:4]) 18 | 19 | ## check GPL and annotate the probes to genes. 20 | gpl=eSet@annotation 21 | checkGPL(gpl) 22 | printGPLInfo(gpl) 23 | probe2gene=idmap(gpl) 24 | head(probe2gene) 25 | genes_expr <- filterEM(probes_expr,probe2gene ) 26 | head(genes_expr) 27 | 28 | # do DEG 29 | ## define the group 30 | group_list= c(rep('Control',3),rep('Diabetes',3)) 31 | table(group_list) 32 | 33 | ## Create DEGContainer 34 | data_i <- Create_DEGContainer( 35 | species = "Human", 36 | dataType = "Array", 37 | expMatrix = genes_expr, 38 | groupInfo = group_list, 39 | caseGroup = "Diabetes",idType = "SYMBOL",filterMethod = NULL 40 | ) 41 | 42 | ## Run workflow 43 | data_o <- runALL(data_i,dir = "testArray",top = 10,parallel = T,GO = T,KEGG = T) 44 | 45 | -------------------------------------------------------------------------------- /dev/Testworkflow.R: -------------------------------------------------------------------------------- 1 | devtools::load_all() 2 | devtools::document() 3 | 4 | # treatInfo(cutFC = NULL,label = c("Down", "Stable", "Up"), 5 | # label_ns = "Stable") 6 | # 7 | # rowSums(counts > 2) >= ncol(counts) 8 | 9 | library(airway) 10 | 11 | data("airway") 12 | 13 | row_counts <- as.data.frame(assay(airway)) 14 | 15 | group_list <- as.character(colData(airway)$dex) 16 | 17 | data_i <- Create_DEGContainer(expMatrix = row_counts, 18 | groupInfo = group_list, 19 | dataType = "Array", 20 | caseGroup = "trt", 21 | idType = "ENSEMBL") 22 | 23 | data_o <- runALL(object = data_i,dir = "output_test") 24 | # data_t <- runMSigDB(obj = data_o,dir = "output_test") 25 | 26 | # runCheck(data_i) 27 | # 28 | # data_g <- runDEG(obj = data_i, parallel = T) 29 | # 30 | # data_h <- runHyper(obj = data_g) 31 | # 32 | # data_gse <- runGSEA(obj = data_h) 33 | # 34 | # data_gsva <- runMSigDB(data_gse) 35 | -------------------------------------------------------------------------------- /dev/bingxing.R: -------------------------------------------------------------------------------- 1 | 2 | 3 | rm(list = "i") 4 | 5 | usethis::ui_info("Enrich KEGG analysis Start. This process will take a few minutes.") 6 | 7 | test <- lapply(gene_list, function(x) 8 | suppressMessages(enrichKEGG( 9 | gene = x, 10 | organism = organism, 11 | keyType = keyType, 12 | pvalueCutoff = pvalueCutoff, 13 | pAdjustMethod = pAdjustMethod, 14 | minGSSize = minGSSize, 15 | maxGSSize = maxGSSize, 16 | qvalueCutoff = qvalueCutoff, 17 | use_internal_data = use_internal_data))) 18 | 19 | my.cluster <- parallel::makeCluster( 20 | spec = length(gene_list), 21 | type = "PSOCK" 22 | ) 23 | doParallel::registerDoParallel(cores = length(gene_list)) 24 | foreach::getDoParWorkers() 25 | res <- list() 26 | `%dopar%` <- foreach::`%dopar%` 27 | require(foreach) 28 | res[[names(gene_list)[i]]] <- foreach::foreach(i = 1:length(gene_list)) %dopar% { 29 | 30 | suppressMessages(clusterProfiler::enrichKEGG( 31 | gene = gene_list[[i]], 32 | organism = "hsa", 33 | keyType = "kegg", 34 | pvalueCutoff = 1, 35 | pAdjustMethod = "BH", 36 | minGSSize = 50, 37 | maxGSSize = 500, 38 | qvalueCutoff = 1, 39 | use_internal_data = T)) 40 | 41 | } 42 | parallel::stopCluster(cl = my.cluster) 43 | -------------------------------------------------------------------------------- /dev/ci.R: -------------------------------------------------------------------------------- 1 | # usethis::use_github_action_check_standard() 2 | # usethis::use_github_actions_badge() 3 | # usethis::use_testthat() 4 | # usethis::use_coverage() 5 | library(covr); codecov() 6 | 7 | # usethis::use_github_action("test-coverage") 8 | -------------------------------------------------------------------------------- /dev/deg_data.Rdata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiayh17/RNAseqStat2/4ae8e3a7a3062c3be0ecfea7811320c7f17bfc17/dev/deg_data.Rdata -------------------------------------------------------------------------------- /dev/git.R: -------------------------------------------------------------------------------- 1 | usethis::use_git() 2 | usethis::use_github() 3 | -------------------------------------------------------------------------------- /dev/license.R: -------------------------------------------------------------------------------- 1 | usethis::use_mit_license() 2 | -------------------------------------------------------------------------------- /dev/load.R: -------------------------------------------------------------------------------- 1 | devtools::document() 2 | devtools::load_all() 3 | -------------------------------------------------------------------------------- /dev/minimal_step.R: -------------------------------------------------------------------------------- 1 | devtools::load_all() 2 | devtools::document() 3 | 4 | # treatInfo(cutFC = NULL,label = c("Down", "Stable", "Up"), 5 | # label_ns = "Stable") 6 | # 7 | # rowSums(counts > 2) >= ncol(counts) 8 | 9 | library(airway) 10 | 11 | data("airway") 12 | 13 | row_counts <- as.data.frame(assay(airway)) 14 | 15 | group_list <- as.character(colData(airway)$dex) 16 | 17 | data_i <- Create_DEGContainer(expMatrix = row_counts, 18 | groupInfo = group_list, 19 | caseGroup = "trt", 20 | idType = "ENSEMBL") 21 | -------------------------------------------------------------------------------- /dev/readme.R: -------------------------------------------------------------------------------- 1 | usethis::use_readme_rmd() 2 | -------------------------------------------------------------------------------- /dev/test_GO.R: -------------------------------------------------------------------------------- 1 | list_ok <- list() 2 | a=c(1,2,3,4,5) 3 | b=c(6,7,8,9,10) 4 | c=c(11,12,13,14,15) 5 | d=c(16, 17, 18, 19, 20) 6 | e=c(21,22,23,24,25) 7 | 8 | list_ok[[1]]=a 9 | list_ok[[2]]=b 10 | list_ok[[3]]=c 11 | list_ok[[4]]=d 12 | list_ok[[5]]=e 13 | 14 | new_list <- vector(mode = "list", length=5) 15 | 16 | for (i in 1:5) { 17 | for(k in 1:5) { 18 | new_list[[i]][k] <- list_ok[[i]][k] 19 | } 20 | } 21 | 22 | new_list 23 | 24 | library(purrr) 25 | 26 | map(list_ok, function(x) 27 | map_dbl(seq_along(list_ok), function(y) x[[y]]) 28 | ) 29 | DEG_df_g <- cut_much(DEG_df,x = "log2FoldChange",y = "pvalue",cut_FC = 2,cut_FDR = 0.01) 30 | gene_list <- list( 31 | Up = row.names(DEG_df_g[which(DEG_df_g$group == "Up"),]), 32 | Down = row.names(DEG_df_g[which(DEG_df_g$group == "Down"),]) 33 | ) 34 | 35 | DEG_df_g <- cut_much(DEG_df,x = "log2FoldChange",y = "pvalue",cut_FC = 2,cut_FDR = 0.01) 36 | ll <- DEG_df_g[which(DEG_df_g$group %in% c("Up","Down")),] 37 | 38 | ont = c("BP","CC","MF","ALL") 39 | 40 | ego <- map(gene_list,function(x) 41 | enhance_enrichGO(gene =x, OrgDb = 'org.Hs.eg.db', keyType = "SYMBOL", ont="BP", pvalueCutoff=0.05) 42 | ) 43 | 44 | GO_DATA <- enhance_get_GO_data(OrgDb = 'org.Hs.eg.db', ont = "ALL", keytype = "SYMBOL") 45 | 46 | microbenchmark::microbenchmark( 47 | test1 <- enhance_enricher_internal(gene = gene_list[[1]], 48 | pvalueCutoff=0.05, 49 | pAdjustMethod="BH", 50 | universe = NULL, 51 | qvalueCutoff = 0.2, 52 | minGSSize = 10, 53 | maxGSSize = 500, 54 | USER_DATA = GO_DATA 55 | ), 56 | 57 | test2 <- DOSE:::enricher_internal( 58 | gene = gene_list[[1]], 59 | pvalueCutoff=0.05, 60 | pAdjustMethod="BH", 61 | universe = NULL, 62 | qvalueCutoff = 0.2, 63 | minGSSize = 10, 64 | maxGSSize = 500, 65 | USER_DATA = GO_DATA 66 | ) 67 | ) 68 | 69 | library(furrr) 70 | plan(multisession, workers = 1) 71 | 72 | tt <- enhance_enrichGO(gene =gene_list[[1]], OrgDb = 'org.Hs.eg.db', 73 | keyType = "SYMBOL", ont="ALL", pvalueCutoff=0.05, simplify = TRUE) 74 | 75 | tt2 <- enrichGO(gene =gene_list[[1]], OrgDb = 'org.Hs.eg.db', keyType = "SYMBOL", ont="ALL", pvalueCutoff=0.05) 76 | 77 | lres <- furrr::future_map(c("BP", "CC", "MF"), function(ont) 78 | suppressMessages(enhance_enrichGO(gene, OrgDb, keyType, ont, 79 | pvalueCutoff, pAdjustMethod, universe, 80 | qvalueCutoff, minGSSize, maxGSSize 81 | )),.options = furrr_options(seed = TRUE) 82 | ) 83 | 84 | lres2 <- lres[!vapply(lres, is.null, logical(1))] 85 | lres3 <- furrr::future_map(lres2, function(x) clusterProfiler::simplify(x)) 86 | 87 | df <- do.call('rbind', future_map(lres, as.data.frame)) 88 | 89 | wt <- as.data.frame(lres[[1]]) 90 | 91 | data(geneList, package = "DOSE") 92 | de <- names(geneList)[1:100] 93 | 94 | library(furrr) 95 | plan(multisession, workers = 1) 96 | # create cluster object 97 | cl <- makeCluster(3) 98 | 99 | # test each number in sample_numbers for primality 100 | microbenchmark::microbenchmark( 101 | ego <- map(gene_list,function(x) 102 | RNAseqStat::enhance_enrichGO(gene =x, OrgDb = 'org.Hs.eg.db', keyType = "SYMBOL", ont="CC", pvalueCutoff=0.05) 103 | ), 104 | # yy1 <- enrichGO(de, 'org.Hs.eg.db', ont="BP", pvalueCutoff=0.01), 105 | ego2 <- furrr::future_map(gene_list,function(x) 106 | RNAseqStat::enhance_enrichGO(gene =x, OrgDb = 'org.Hs.eg.db', keyType = "SYMBOL", ont="CC", pvalueCutoff=0.05) 107 | ), 108 | ego3 <- parLapply(cl,gene_list,function(x) 109 | RNAseqStat::enhance_enrichGO(gene =x, OrgDb = 'org.Hs.eg.db', keyType = "SYMBOL", ont="CC", pvalueCutoff=0.05)), 110 | times = 1L 111 | ) 112 | 113 | # close cluster object 114 | stopCluster(cl) 115 | 116 | -------------------------------------------------------------------------------- /dev/theme.R: -------------------------------------------------------------------------------- 1 | # fig size 2 | width = 400/100, height = 350/100, dpi = 300, units = "in" 3 | # long size 4 | height = 550/100 5 | # group color 6 | palette = RColorBrewer::brewer.pal(3,"Set2")[1:2] 7 | -------------------------------------------------------------------------------- /dev/usepackages.R: -------------------------------------------------------------------------------- 1 | usethis::use_package("glue") 2 | usethis::use_package("edgeR") 3 | usethis::use_package("fs") 4 | usethis::use_package("usethis") 5 | usethis::use_package("DESeq2") 6 | usethis::use_package("SummarizedExperiment") 7 | usethis::use_package("FactoMineR") 8 | usethis::use_package("factoextra") 9 | usethis::use_package("ggplot2") 10 | usethis::use_package("RColorBrewer") 11 | usethis::use_package("pheatmap") 12 | usethis::use_package("data.table") 13 | usethis::use_package("utils") 14 | usethis::use_package("ggrepel") 15 | usethis::use_package("stats") 16 | usethis::use_package("GSEABase") 17 | usethis::use_package("DOSE") 18 | usethis::use_package("GSVA") 19 | usethis::use_package("msigdbr") 20 | usethis::use_package("clusterProfiler") 21 | usethis::use_package("AnnoProbe") 22 | usethis::use_package("kit") 23 | usethis::use_package("limma") 24 | usethis::use_package("methods") 25 | usethis::use_package("qvalue") 26 | usethis::use_package("ggtext") 27 | usethis::use_package("ggdist") 28 | usethis::use_package("grid") 29 | usethis::use_package("dplyr") 30 | usethis::use_package("forcats") 31 | usethis::use_package("ggridges") 32 | usethis::use_package("ggnewscale") 33 | usethis::use_package("stringr") 34 | usethis::use_package("enrichplot") 35 | usethis::use_package("plyr") 36 | -------------------------------------------------------------------------------- /man/Create_DEGContainer.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/CreateDEGContainer.R 3 | \name{Create_DEGContainer} 4 | \alias{Create_DEGContainer} 5 | \title{Create \code{DEGContainer}} 6 | \usage{ 7 | Create_DEGContainer( 8 | species = "Human", 9 | dataType = "Counts", 10 | idType = "SYMBOL", 11 | expMatrix, 12 | groupInfo, 13 | caseGroup, 14 | filterMethod = "rowSums(expMatrix > 0) >= ncol(expMatrix)/2", 15 | msi_species = NULL, 16 | msi_category = "H", 17 | OrgDb = NULL, 18 | organism = NULL, 19 | GOTERM2GENE = NULL, 20 | GOTERM2NAME = NA, 21 | KEGGTERM2GENE = NULL, 22 | KEGGTERM2NAME = NA 23 | ) 24 | } 25 | \arguments{ 26 | \item{species}{species for your data.} 27 | 28 | \item{dataType}{kind of expresses value matrix. `Counts` (Integer) or `Array` (Decimal).} 29 | 30 | \item{idType}{kind of gene id. `ENSEMBL` or `SYMBOL`, If `ENSEMBL`,\code{species} supposed be one of (`Human`, `Mouse` and `Rat`), it will be automatically converted to `SYMBOL`.} 31 | 32 | \item{expMatrix}{expresses value matrix. Should be a data.frame row named by gene ID and column named by Sample} 33 | 34 | \item{groupInfo}{a Character Vectors ordered by samples in matrix.} 35 | 36 | \item{caseGroup}{a Character names of case group.} 37 | 38 | \item{filterMethod}{a function used to filter expresses value matrix. Or disable filter by set as `NULL`.} 39 | 40 | \item{msi_species}{one of \code{\link[msigdbr]{msigdbr_species}}} 41 | 42 | \item{msi_category}{MSigDB collection abbreviation, such as H or C1.} 43 | 44 | \item{OrgDb}{Select an OrgDb.} 45 | 46 | \item{organism}{Select an organism.} 47 | 48 | \item{GOTERM2GENE}{custom enrich data of GO.} 49 | 50 | \item{GOTERM2NAME}{custom enrich data of GO.} 51 | 52 | \item{KEGGTERM2GENE}{custom enrich data of GSE.} 53 | 54 | \item{KEGGTERM2NAME}{custom enrich data of GSE.} 55 | } 56 | \value{ 57 | a \code{DEGContainer} object 58 | } 59 | \description{ 60 | Begin in DEGContainer. 61 | } 62 | \details{ 63 | `Human`, `Mouse` and `Rat` is full supported. For other species, more setting is needed. \cr 64 | If data can't provided, related steps in workflow will ignore. \cr 65 | OrgDb can be find from here \link{https://bioconductor.org/packages/release/BiocViews.html#___OrgDb} \cr 66 | organism can be find from here \link{https://www.genome.jp/kegg/catalog/org_list.html} \cr 67 | msi_species can be get from \code{\link[msigdbr]{msigdbr_species}} \cr 68 | } 69 | \examples{ 70 | Create_DEGContainer(expMatrix = counts_input,groupInfo = c("C","C","C","T","T","T"),caseGroup = "T") 71 | } 72 | -------------------------------------------------------------------------------- /man/Create_MSigDB.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/createOB.R 3 | \name{Create_MSigDB} 4 | \alias{Create_MSigDB} 5 | \title{Create \code{MSigDB}} 6 | \usage{ 7 | Create_MSigDB( 8 | msigdbParam = Create_msigdbParam(), 9 | msigdbGSEAparam = Create_msigdbGSEAparam(), 10 | msigdbHyperParam = Create_msigdbHyperParam() 11 | ) 12 | } 13 | \arguments{ 14 | \item{msigdbParam}{from \code{Create_msigdbParam}} 15 | 16 | \item{msigdbGSEAparam}{from \code{Create_msigdbGSEAparam}} 17 | 18 | \item{msigdbHyperParam}{from \code{Create_msigdbHyperParam}} 19 | } 20 | \value{ 21 | a \code{MSigDB} object 22 | } 23 | \description{ 24 | Create a MSigDB object. 25 | } 26 | -------------------------------------------------------------------------------- /man/Create_dataInfo.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/createOB.R 3 | \name{Create_dataInfo} 4 | \alias{Create_dataInfo} 5 | \title{create \code{dataInfo}} 6 | \usage{ 7 | Create_dataInfo( 8 | species, 9 | dataType, 10 | idType, 11 | expMatrix, 12 | groupInfo, 13 | caseGroup, 14 | filterMethod, 15 | matrixFiltered 16 | ) 17 | } 18 | \arguments{ 19 | \item{species}{species for your data. `Human` or `Mouse`} 20 | 21 | \item{dataType}{kind of expresses value matrix. `Counts` (Integer) or `Array` (Decimal).} 22 | 23 | \item{idType}{kind of gene id. `ENSEMBL` or `SYMBOL`, If `ENSEMBL`, it will be automatically converted to `SYMBOL`.} 24 | 25 | \item{expMatrix}{expresses value matrix. Should be a data.frame row named by gene ID and column named by Sample} 26 | 27 | \item{groupInfo}{a Character Vectors ordered by samples in matrix.} 28 | 29 | \item{caseGroup}{a Character names of case group.} 30 | 31 | \item{filterMethod}{a function used to filter expresses value matrix.} 32 | 33 | \item{matrixFiltered}{a expresses value matrix after filter by `filterMethod`.} 34 | } 35 | \value{ 36 | dataInfo 37 | } 38 | \description{ 39 | a function to create \code{\link{dataInfo}} OB 40 | } 41 | -------------------------------------------------------------------------------- /man/Create_gseParam.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/createParam.R 3 | \name{Create_gseParam} 4 | \alias{Create_gseParam} 5 | \title{Create param for gse analysis} 6 | \usage{ 7 | Create_gseParam( 8 | goParam = NULL, 9 | keggParam = NULL, 10 | customGO = FALSE, 11 | customKEGG = FALSE, 12 | skipGO = FALSE, 13 | skipKEGG = FALSE 14 | ) 15 | } 16 | \arguments{ 17 | \item{goParam}{arguments in \code{\link[clusterProfiler]{gseGO}} or \code{\link[clusterProfiler]{GSEA}} except \code{geneList}.} 18 | 19 | \item{keggParam}{arguments in \code{\link[clusterProfiler]{gseKEGG}} or \code{\link[clusterProfiler]{GSEA}} except \code{geneList}.} 20 | 21 | \item{customGO}{logic. FALSE for \code{\link[clusterProfiler]{gseGO}}, TRUE for \code{\link[clusterProfiler]{GSEA}}} 22 | 23 | \item{customKEGG}{logic. FALSE for \code{\link[clusterProfiler]{gseKEGG}}, TRUE for \code{\link[clusterProfiler]{GSEA}}} 24 | 25 | \item{skipGO}{logical, set parameters as NULL for skip this step} 26 | 27 | \item{skipKEGG}{logical, set parameters as NULL for skip this step} 28 | } 29 | \value{ 30 | gseParam 31 | } 32 | \description{ 33 | Create param for gse analysis 34 | } 35 | \examples{ 36 | Create_gseParam() 37 | } 38 | -------------------------------------------------------------------------------- /man/Create_hyperParam.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/createParam.R 3 | \name{Create_hyperParam} 4 | \alias{Create_hyperParam} 5 | \title{Create param for hyper analysis} 6 | \usage{ 7 | Create_hyperParam( 8 | goParam = NULL, 9 | keggParam = NULL, 10 | customGO = FALSE, 11 | customKEGG = FALSE, 12 | skipGO = FALSE, 13 | skipKEGG = FALSE 14 | ) 15 | } 16 | \arguments{ 17 | \item{goParam}{arguments in \code{\link[clusterProfiler]{enrichGO}} or \code{\link[clusterProfiler]{enricher}} except \code{gene}.} 18 | 19 | \item{keggParam}{arguments in \code{\link[clusterProfiler]{enrichKEGG}} or \code{\link[clusterProfiler]{enricher}} except \code{gene}.} 20 | 21 | \item{customGO}{logic. FALSE for \code{\link[clusterProfiler]{enrichGO}}, TRUE for \code{\link[clusterProfiler]{enricher}}} 22 | 23 | \item{customKEGG}{logic. FALSE for \code{\link[clusterProfiler]{enrichKEGG}}, TRUE for \code{\link[clusterProfiler]{enricher}}} 24 | 25 | \item{skipGO}{logical, set parameters as NULL for skip this step} 26 | 27 | \item{skipKEGG}{logical, set parameters as NULL for skip this step} 28 | } 29 | \value{ 30 | hyperParam 31 | } 32 | \description{ 33 | Create param for hyper analysis 34 | } 35 | \examples{ 36 | Create_hyperParam() 37 | } 38 | -------------------------------------------------------------------------------- /man/Create_msigdbGSEAparam.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/createParam.R 3 | \name{Create_msigdbGSEAparam} 4 | \alias{Create_msigdbGSEAparam} 5 | \title{Create \code{msigdbGSEAparam}} 6 | \usage{ 7 | Create_msigdbGSEAparam(GSEAparam = NULL) 8 | } 9 | \arguments{ 10 | \item{GSEAparam}{a list contains any paramaters of \code{\link[clusterProfiler]{GSEA}} except \code{geneList}} 11 | } 12 | \value{ 13 | a list 14 | } 15 | \description{ 16 | Create a msigdbHyperParam list. If NULL, default parameters will apply. 17 | } 18 | \examples{ 19 | Create_msigdbGSEAparam() 20 | } 21 | -------------------------------------------------------------------------------- /man/Create_msigdbHyperParam.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/createParam.R 3 | \name{Create_msigdbHyperParam} 4 | \alias{Create_msigdbHyperParam} 5 | \title{Create \code{msigdbHyperParam}} 6 | \usage{ 7 | Create_msigdbHyperParam(HyperParam = NULL) 8 | } 9 | \arguments{ 10 | \item{GSEAparam}{a list contains any paramaters of \code{\link[clusterProfiler]{enricher}} except \code{geneList}} 11 | } 12 | \value{ 13 | a list 14 | } 15 | \description{ 16 | Create a msigdbHyperParam list. If NULL, default parameters will apply. 17 | } 18 | \examples{ 19 | Create_msigdbHyperParam() 20 | } 21 | -------------------------------------------------------------------------------- /man/Create_msigdbParam.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/createParam.R 3 | \name{Create_msigdbParam} 4 | \alias{Create_msigdbParam} 5 | \title{Create \code{MSigDB}} 6 | \usage{ 7 | Create_msigdbParam(msigdbParam = NULL, skipMSigDB = FALSE) 8 | } 9 | \arguments{ 10 | \item{msigdbParam}{a list contains any paramaters of \code{\link[msigdbr]{msigdbr}}} 11 | 12 | \item{skipMSigDB}{logical, set parameters as NULL for skip this step} 13 | } 14 | \value{ 15 | a list 16 | } 17 | \description{ 18 | Create a msigdbParam list. If NULL, default parameters will apply. 19 | } 20 | \examples{ 21 | Create_msigdbParam() 22 | } 23 | -------------------------------------------------------------------------------- /man/Create_treatInfo.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/createOB.R 3 | \name{Create_treatInfo} 4 | \alias{Create_treatInfo} 5 | \title{Function for treatInfo} 6 | \usage{ 7 | Create_treatInfo( 8 | cutFC = NULL, 9 | cutFDR = 0.05, 10 | label = c("Down", "Stable", "Up"), 11 | label_ns = "Stable", 12 | sigCol = c("#2874C5", "grey", "#f87669"), 13 | sigAlpha = c(1, 0.5, 1), 14 | sigSize = c(0.6, 0.5, 0.6), 15 | sigShape = 16 16 | ) 17 | } 18 | \arguments{ 19 | \item{cutFC}{a numeric or list. Threshold of logFC for finding significantly different genes.} 20 | 21 | \item{cutFDR}{a numeric. Threshold of Pvalue for finding significantly different genes.} 22 | 23 | \item{label}{a character vector. Name for every group} 24 | 25 | \item{label_ns}{a character. Name of no signification group} 26 | 27 | \item{sigCol}{a character vector. sigColor of every group} 28 | 29 | \item{sigAlpha}{a numeric vector. transparency for every group} 30 | } 31 | \value{ 32 | treatInfo 33 | } 34 | \description{ 35 | Function for treatInfo 36 | } 37 | -------------------------------------------------------------------------------- /man/DEGContainer.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/allClass.R, R/allMethods.R 3 | \docType{methods} 4 | \name{DEGContainer} 5 | \alias{DEGContainer} 6 | \alias{DEGContainer-class} 7 | \alias{species<-,DEGContainer-method} 8 | \alias{dataType<-,DEGContainer-method} 9 | \alias{idType<-,DEGContainer-method} 10 | \alias{expMatrix<-,DEGContainer-method} 11 | \alias{groupInfo<-,DEGContainer-method} 12 | \alias{caseGroup<-,DEGContainer-method} 13 | \alias{filterMethod<-,DEGContainer-method} 14 | \alias{matrixFiltered<-,DEGContainer-method} 15 | \alias{geneNames<-,DEGContainer-method} 16 | \alias{sampleNames<-,DEGContainer-method} 17 | \alias{treatInfo,DEGContainer-method} 18 | \alias{label,DEGContainer-method} 19 | \alias{label_ns,DEGContainer-method} 20 | \alias{cutFC,DEGContainer-method} 21 | \alias{cutFDR,DEGContainer-method} 22 | \alias{sigCol,DEGContainer-method} 23 | \alias{sigAlpha,DEGContainer-method} 24 | \alias{sigSize,DEGContainer-method} 25 | \alias{sigShape,DEGContainer-method} 26 | \alias{treatInfo<-,DEGContainer-method} 27 | \alias{cutFC<-,DEGContainer-method} 28 | \alias{cutFDR<-,DEGContainer-method} 29 | \alias{label<-,DEGContainer-method} 30 | \alias{label_ns<-,DEGContainer-method} 31 | \alias{sigCol<-,DEGContainer-method} 32 | \alias{sigAlpha<-,DEGContainer-method} 33 | \alias{sigSize<-,DEGContainer-method} 34 | \alias{sigShape<-,DEGContainer-method} 35 | \alias{vsData,DEGContainer-method} 36 | \alias{limma_res,DEGContainer-method} 37 | \alias{edgeR_res,DEGContainer-method} 38 | \alias{DESeq2_res,DEGContainer-method} 39 | \alias{merge_res,DEGContainer-method} 40 | \alias{vsData<-,DEGContainer-method} 41 | \alias{DESeq2_res<-,DEGContainer-method} 42 | \alias{limma_res<-,DEGContainer-method} 43 | \alias{edgeR_res<-,DEGContainer-method} 44 | \alias{merge_res<-,DEGContainer-method} 45 | \alias{hyperKEGGparam,DEGContainer-method} 46 | \alias{hyperKEGGparam<-,DEGContainer-method} 47 | \alias{hyperGOparam,DEGContainer-method} 48 | \alias{hyperGOparam<-,DEGContainer-method} 49 | \alias{hyperRes,DEGContainer-method} 50 | \alias{hyperRes<-,DEGContainer-method} 51 | \alias{gseKEGGparam,DEGContainer-method} 52 | \alias{gseKEGGparam<-,DEGContainer-method} 53 | \alias{gseGOparam,DEGContainer-method} 54 | \alias{gseGOparam<-,DEGContainer-method} 55 | \alias{gseRes,DEGContainer-method} 56 | \alias{gseRes<-,DEGContainer-method} 57 | \alias{msigdbParam,DEGContainer-method} 58 | \alias{msigdbGSEAparam,DEGContainer-method} 59 | \alias{msigdbHyperParam,DEGContainer-method} 60 | \alias{msigdbParam<-,DEGContainer-method} 61 | \alias{msigdbGSEAparam<-,DEGContainer-method} 62 | \alias{msigdbHyperParam<-,DEGContainer-method} 63 | \alias{msigdbData,DEGContainer-method} 64 | \alias{msigdbData<-,DEGContainer-method} 65 | \alias{msigdbGSEAresult,DEGContainer-method} 66 | \alias{msigdbGSEAresult<-,DEGContainer-method} 67 | \alias{msigdbHyperResult,DEGContainer-method} 68 | \alias{msigdbHyperResult<-,DEGContainer-method} 69 | \alias{msigdbGSVAresult,DEGContainer-method} 70 | \alias{msigdbGSVAresult<-,DEGContainer-method} 71 | \alias{msigdbTreat,DEGContainer-method} 72 | \alias{msigdbTreat<-,DEGContainer-method} 73 | \title{Class \code{DEGContainer}} 74 | \usage{ 75 | \S4method{species}{DEGContainer}(obj) <- value 76 | 77 | \S4method{dataType}{DEGContainer}(obj) <- value 78 | 79 | \S4method{idType}{DEGContainer}(obj) <- value 80 | 81 | \S4method{expMatrix}{DEGContainer}(obj) <- value 82 | 83 | \S4method{groupInfo}{DEGContainer}(obj) <- value 84 | 85 | \S4method{caseGroup}{DEGContainer}(obj) <- value 86 | 87 | \S4method{filterMethod}{DEGContainer}(obj) <- value 88 | 89 | \S4method{matrixFiltered}{DEGContainer}(obj) <- value 90 | 91 | \S4method{geneNames}{DEGContainer}(obj, filtered = FALSE) <- value 92 | 93 | \S4method{sampleNames}{DEGContainer}(obj, filtered = FALSE) <- value 94 | 95 | \S4method{treatInfo}{DEGContainer}(obj) 96 | 97 | \S4method{label}{DEGContainer}(obj) 98 | 99 | \S4method{label_ns}{DEGContainer}(obj) 100 | 101 | \S4method{cutFC}{DEGContainer}(obj) 102 | 103 | \S4method{cutFDR}{DEGContainer}(obj) 104 | 105 | \S4method{sigCol}{DEGContainer}(obj) 106 | 107 | \S4method{sigAlpha}{DEGContainer}(obj) 108 | 109 | \S4method{sigSize}{DEGContainer}(obj) 110 | 111 | \S4method{sigShape}{DEGContainer}(obj) 112 | 113 | \S4method{treatInfo}{DEGContainer}(obj) <- value 114 | 115 | \S4method{cutFC}{DEGContainer}(obj) <- value 116 | 117 | \S4method{cutFDR}{DEGContainer}(obj) <- value 118 | 119 | \S4method{label}{DEGContainer}(obj) <- value 120 | 121 | \S4method{label_ns}{DEGContainer}(obj) <- value 122 | 123 | \S4method{sigCol}{DEGContainer}(obj) <- value 124 | 125 | \S4method{sigAlpha}{DEGContainer}(obj) <- value 126 | 127 | \S4method{sigSize}{DEGContainer}(obj) <- value 128 | 129 | \S4method{sigShape}{DEGContainer}(obj) <- value 130 | 131 | \S4method{vsData}{DEGContainer}(obj) 132 | 133 | \S4method{limma_res}{DEGContainer}(obj) 134 | 135 | \S4method{edgeR_res}{DEGContainer}(obj) 136 | 137 | \S4method{DESeq2_res}{DEGContainer}(obj) 138 | 139 | \S4method{merge_res}{DEGContainer}(obj) 140 | 141 | \S4method{vsData}{DEGContainer}(obj) <- value 142 | 143 | \S4method{DESeq2_res}{DEGContainer}(obj) <- value 144 | 145 | \S4method{limma_res}{DEGContainer}(obj) <- value 146 | 147 | \S4method{edgeR_res}{DEGContainer}(obj) <- value 148 | 149 | \S4method{merge_res}{DEGContainer}(obj) <- value 150 | 151 | \S4method{hyperKEGGparam}{DEGContainer}(obj) 152 | 153 | \S4method{hyperKEGGparam}{DEGContainer}(obj) <- value 154 | 155 | \S4method{hyperGOparam}{DEGContainer}(obj) 156 | 157 | \S4method{hyperGOparam}{DEGContainer}(obj) <- value 158 | 159 | \S4method{hyperRes}{DEGContainer}(obj) 160 | 161 | \S4method{hyperRes}{DEGContainer}(obj) <- value 162 | 163 | \S4method{gseKEGGparam}{DEGContainer}(obj) 164 | 165 | \S4method{gseKEGGparam}{DEGContainer}(obj) <- value 166 | 167 | \S4method{gseGOparam}{DEGContainer}(obj) 168 | 169 | \S4method{gseGOparam}{DEGContainer}(obj) <- value 170 | 171 | \S4method{gseRes}{DEGContainer}(obj) 172 | 173 | \S4method{gseRes}{DEGContainer}(obj) <- value 174 | 175 | \S4method{msigdbParam}{DEGContainer}(obj) 176 | 177 | \S4method{msigdbGSEAparam}{DEGContainer}(obj) 178 | 179 | \S4method{msigdbHyperParam}{DEGContainer}(obj) 180 | 181 | \S4method{msigdbParam}{DEGContainer}(obj) <- value 182 | 183 | \S4method{msigdbGSEAparam}{DEGContainer}(obj) <- value 184 | 185 | \S4method{msigdbHyperParam}{DEGContainer}(obj) <- value 186 | 187 | \S4method{msigdbData}{DEGContainer}(obj) 188 | 189 | \S4method{msigdbData}{DEGContainer}(obj) <- value 190 | 191 | \S4method{msigdbGSEAresult}{DEGContainer}(obj) 192 | 193 | \S4method{msigdbGSEAresult}{DEGContainer}(obj) <- value 194 | 195 | \S4method{msigdbHyperResult}{DEGContainer}(obj) 196 | 197 | \S4method{msigdbHyperResult}{DEGContainer}(obj) <- value 198 | 199 | \S4method{msigdbGSVAresult}{DEGContainer}(obj) 200 | 201 | \S4method{msigdbGSVAresult}{DEGContainer}(obj) <- value 202 | 203 | \S4method{msigdbTreat}{DEGContainer}(obj) 204 | 205 | \S4method{msigdbTreat}{DEGContainer}(obj) <- value 206 | } 207 | \value{ 208 | The accessor functions \code{dataInfo}, \code{degResults}, 209 | \code{hyperResults}, \code{gseResults}, \code{MSigDB} return 210 | the corresponding elements of a 211 | \code{DEGContainer}. 212 | } 213 | \description{ 214 | This was the universal class for storing data and 215 | results. We now generally reommend using the 216 | \code{\link{Create_DEGContainer}} to create it. 217 | } 218 | \section{Slots}{ 219 | 220 | \describe{ 221 | \item{\code{dataInfo}}{store input data of workflow} 222 | 223 | \item{\code{degResults}}{store parameters and results in \code{runDEG} module} 224 | 225 | \item{\code{hyperResults}}{store parameters and results in \code{runHyper} module} 226 | 227 | \item{\code{gseResults}}{store parameters and results in \code{runGSEA} module} 228 | 229 | \item{\code{MSigDB}}{store parameters and results in \code{runMSigDB} module} 230 | }} 231 | 232 | -------------------------------------------------------------------------------- /man/DEGtopHeatmap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_DEG.R 3 | \name{DEGtopHeatmap} 4 | \alias{DEGtopHeatmap} 5 | \title{Heatmap for DEG data frame} 6 | \usage{ 7 | DEGtopHeatmap( 8 | object, 9 | which, 10 | top = 50, 11 | filename = NA, 12 | show_gene = TRUE, 13 | category = "H", 14 | palette = RColorBrewer::brewer.pal(3, "Set2")[1:2], 15 | ... 16 | ) 17 | } 18 | \arguments{ 19 | \item{object}{a counts data frame of rows in genes and columns in samples} 20 | 21 | \item{which}{which model of deg analysis. kinds of DEG; can be "limma", "edgeR", "DESeq2" or "MSigDB"} 22 | 23 | \item{top}{a single number or a length of 2 numeric vector, if 2 numeric vector, first one is top max logFC.} 24 | 25 | \item{filename}{NA or a file path} 26 | 27 | \item{show_gene}{logical,show gene name} 28 | 29 | \item{category}{MSigDB collection abbreviation, such as H or C1.} 30 | 31 | \item{palette}{a color palette for plots} 32 | 33 | \item{...}{More \code{\link[pheatmap]{pheatmap}} parameters.} 34 | } 35 | \value{ 36 | a heatmap plot file 37 | } 38 | \description{ 39 | default will return a top 100 deg heatmap in p value = 0.05 40 | } 41 | \examples{ 42 | DEGtopHeatmap(object,which = "limma") 43 | } 44 | -------------------------------------------------------------------------------- /man/DEGvenn.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_DEG.R 3 | \name{DEGvenn} 4 | \alias{DEGvenn} 5 | \title{Plot venn for a set of gene} 6 | \usage{ 7 | DEGvenn(geneSets, palette = c("#1f78b4", "#33a02c", "#ff7f00")) 8 | } 9 | \arguments{ 10 | \item{geneSets}{a list of gene sets} 11 | 12 | \item{palette}{palette} 13 | } 14 | \value{ 15 | a plot of venn 16 | } 17 | \description{ 18 | Plot venn for a set of gene 19 | } 20 | \examples{ 21 | DEGvenn(geneSets) 22 | } 23 | -------------------------------------------------------------------------------- /man/DESeq2_resolve.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/degResolve.R 3 | \name{DESeq2_resolve} 4 | \alias{DESeq2_resolve} 5 | \title{Basic produce of DESeq2} 6 | \usage{ 7 | DESeq2_resolve( 8 | counts_data, 9 | group_list, 10 | case_group, 11 | control_group, 12 | qc = TRUE, 13 | dir = ".", 14 | prefix = "2-DEG_DEseq2", 15 | parallel = FALSE 16 | ) 17 | } 18 | \arguments{ 19 | \item{counts_data}{a counts data frame of rows in genes and columns in samples} 20 | 21 | \item{group_list}{a character vector ordered by samples in counts_data} 22 | 23 | \item{case_group}{the name of the numerator level for the fold change (Test group)} 24 | 25 | \item{control_group}{the name of the denominator level for the fold change (Control group)} 26 | 27 | \item{qc}{qc plots} 28 | 29 | \item{dir}{a directory to store results} 30 | 31 | \item{prefix}{a prefix of file names in this step} 32 | 33 | \item{parallel}{if FALSE, no parallelization. if TRUE, parallel execution using BiocParallel} 34 | } 35 | \value{ 36 | a DEG data frame 37 | } 38 | \description{ 39 | A basic function to get data and produce results of DESeq2 40 | } 41 | \examples{ 42 | \dontrun{ 43 | DESeq2_resolve(counts_input, group_list,case_group = "T", control_group = "C", dir = tempdir()) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /man/FC_Identify.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{FC_Identify} 4 | \alias{FC_Identify} 5 | \title{Identify the column where the FC is located} 6 | \usage{ 7 | FC_Identify(res) 8 | } 9 | \arguments{ 10 | \item{res}{one of result from limma or DESeq2 or edgeR} 11 | } 12 | \value{ 13 | a column name 14 | } 15 | \description{ 16 | Identify the column where the FC is located 17 | } 18 | \examples{ 19 | FC_Identify(deg_data) 20 | } 21 | -------------------------------------------------------------------------------- /man/GSEAbar.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_gse.R 3 | \name{GSEAbar} 4 | \alias{GSEAbar} 5 | \title{gseKEGG bar plot} 6 | \usage{ 7 | GSEAbar(res, top = 10) 8 | } 9 | \arguments{ 10 | \item{top}{top rows of up and down} 11 | 12 | \item{data}{a enrich_gsekegg result} 13 | 14 | \item{pvalue_cut}{filter by pvalue} 15 | 16 | \item{enrichmentScore_cut}{filter by enrichmentScore} 17 | } 18 | \value{ 19 | ggplot ob 20 | } 21 | \description{ 22 | plot for enrich_gsekegg result 23 | } 24 | \examples{ 25 | \dontrun{ 26 | test <- enrich_gsekegg(DEG_df,x = "log2FoldChange") 27 | geskegg_barplot(test) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /man/GSEAplot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_gse.R 3 | \name{GSEAplot} 4 | \alias{GSEAplot} 5 | \title{plot gseKEGG plot} 6 | \usage{ 7 | GSEAplot(res, top = 10) 8 | } 9 | \arguments{ 10 | \item{res}{output from gse} 11 | 12 | \item{top}{filter top by pvalue} 13 | 14 | \item{pvalue_cut}{filter cut of pvalue} 15 | 16 | \item{enrichmentScore_cut}{filter cut of enrichmentScore} 17 | } 18 | \value{ 19 | a list contains up and down 20 | } 21 | \description{ 22 | plot gseKEGG plots by up and down 23 | } 24 | \examples{ 25 | \dontrun{ 26 | gsekegg_res <- enrich_gsekegg(DEG_df,x = "log2FoldChange") 27 | plots_l <- enhance_gseplot(gsekegg_res) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /man/HKG_check.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/runCheck.R 3 | \name{HKG_check} 4 | \alias{HKG_check} 5 | \title{Human housekeeping genes expression} 6 | \usage{ 7 | HKG_check( 8 | data, 9 | group, 10 | dir = ".", 11 | prefix = "1-run_check", 12 | palette = RColorBrewer::brewer.pal(3, "Set2")[1:2] 13 | ) 14 | } 15 | \arguments{ 16 | \item{data}{a cpm data frame of rows in genes and columns in samples} 17 | 18 | \item{group}{a list ordered by samples in data} 19 | 20 | \item{dir}{a directory to store results} 21 | 22 | \item{prefix}{a prefix of file names in this step} 23 | 24 | \item{palette}{a color palette for plots} 25 | } 26 | \value{ 27 | a heatmap plot file 28 | } 29 | \description{ 30 | Check Human housekeeping genes expression 31 | } 32 | \examples{ 33 | HKG_check(data,group) 34 | } 35 | -------------------------------------------------------------------------------- /man/MSigDB.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/allClass.R, R/allMethods.R 3 | \docType{methods} 4 | \name{MSigDB} 5 | \alias{MSigDB} 6 | \alias{MSigDB-class} 7 | \alias{msigdbParam,MSigDB-method} 8 | \alias{msigdbGSEAparam,MSigDB-method} 9 | \alias{msigdbHyperParam,MSigDB-method} 10 | \alias{msigdbParam<-,MSigDB-method} 11 | \alias{msigdbGSEAparam<-,MSigDB-method} 12 | \alias{msigdbHyperParam<-,MSigDB-method} 13 | \alias{msigdbData,MSigDB-method} 14 | \alias{msigdbData<-,MSigDB-method} 15 | \alias{msigdbGSEAresult,MSigDB-method} 16 | \alias{msigdbGSEAresult<-,MSigDB-method} 17 | \alias{msigdbHyperResult,MSigDB-method} 18 | \alias{msigdbHyperResult<-,MSigDB-method} 19 | \alias{msigdbGSVAresult,MSigDB-method} 20 | \alias{msigdbGSVAresult<-,MSigDB-method} 21 | \alias{msigdbTreat,MSigDB-method} 22 | \alias{msigdbTreat<-,MSigDB-method} 23 | \title{Class \code{MSigDB}} 24 | \usage{ 25 | \S4method{msigdbParam}{MSigDB}(obj) 26 | 27 | \S4method{msigdbGSEAparam}{MSigDB}(obj) 28 | 29 | \S4method{msigdbHyperParam}{MSigDB}(obj) 30 | 31 | \S4method{msigdbParam}{MSigDB}(obj) <- value 32 | 33 | \S4method{msigdbGSEAparam}{MSigDB}(obj) <- value 34 | 35 | \S4method{msigdbHyperParam}{MSigDB}(obj) <- value 36 | 37 | \S4method{msigdbData}{MSigDB}(obj) 38 | 39 | \S4method{msigdbData}{MSigDB}(obj) <- value 40 | 41 | \S4method{msigdbGSEAresult}{MSigDB}(obj) 42 | 43 | \S4method{msigdbGSEAresult}{MSigDB}(obj) <- value 44 | 45 | \S4method{msigdbHyperResult}{MSigDB}(obj) 46 | 47 | \S4method{msigdbHyperResult}{MSigDB}(obj) <- value 48 | 49 | \S4method{msigdbGSVAresult}{MSigDB}(obj) 50 | 51 | \S4method{msigdbGSVAresult}{MSigDB}(obj) <- value 52 | 53 | \S4method{msigdbTreat}{MSigDB}(obj) 54 | 55 | \S4method{msigdbTreat}{MSigDB}(obj) <- value 56 | } 57 | \value{ 58 | The accessor functions \code{msigdbParam}, \code{msigdbData}, 59 | \code{msigdbGSEAparam}, \code{msigdbGSEAresult}, \code{msigdbGSVAresult} 60 | return the corresponding elements of a 61 | \code{DEGContainer} or \code{MSigDB}. 62 | } 63 | \description{ 64 | This was the class for storing data from MSigDB and analysis 65 | results. 66 | We now generally recommend using the \code{\link{Create_DEGContainer}} 67 | to create it in \code{DEGContainer} obj. 68 | } 69 | \section{Slots}{ 70 | 71 | \describe{ 72 | \item{\code{msigdbParam}}{list_OR_NULL. Store Param of \code{\link[msigdbr]{msigdbr}}} 73 | 74 | \item{\code{msigdbData}}{list. Save data download from MSigDB by \code{\link[msigdbr]{msigdbr}}.} 75 | 76 | \item{\code{msigdbGSEAparam}}{list_OR_NULL. Store Param of \code{\link[clusterProfiler]{GSEA}}} 77 | 78 | \item{\code{msigdbHyperParam}}{list_OR_NULL. Store Param of \code{\link[clusterProfiler]{enricher}}} 79 | 80 | \item{\code{msigdbGSEAresult}}{list. Store results of GSEA.} 81 | 82 | \item{\code{msigdbHyperResult}}{list. Store results of Hyper} 83 | 84 | \item{\code{msigdbGSVAresult}}{list. Store results of GSVA.} 85 | }} 86 | 87 | \seealso{ 88 | Other DEGContainer: 89 | \code{\link{dataInfo}}, 90 | \code{\link{degResults-class}} 91 | } 92 | \concept{DEGContainer} 93 | -------------------------------------------------------------------------------- /man/MSigDBSummary.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/MSigDBSummary.R 3 | \name{MSigDBSummary} 4 | \alias{MSigDBSummary} 5 | \title{Summary MSigDB modules results} 6 | \usage{ 7 | MSigDBSummary(obj, dir = ".", prefix = "5-runMSigDB", top = 10) 8 | } 9 | \arguments{ 10 | \item{obj}{a DEGContainer} 11 | 12 | \item{dir}{a directory to store results} 13 | 14 | \item{prefix}{a prefix of file names in this step} 15 | 16 | \item{top}{top of hyper or gsea} 17 | } 18 | \description{ 19 | Summary MSigDB modules results 20 | } 21 | \examples{ 22 | MSigDBSummary(data_msigdb) 23 | } 24 | -------------------------------------------------------------------------------- /man/PointVolcano.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_DEGvolcano.R 3 | \name{PointVolcano} 4 | \alias{PointVolcano} 5 | \title{Showing gene labels and highlighting gene points in a volcano plot in ggplot} 6 | \usage{ 7 | PointVolcano( 8 | object, 9 | which, 10 | category = "H", 11 | gene, 12 | light = NULL, 13 | light_color = "#24ac56", 14 | light_label_color = "#24ac56", 15 | expend = c(0.12, 0.12), 16 | nudge_y_up = -6.5, 17 | nudge_y_down = -4 18 | ) 19 | } 20 | \arguments{ 21 | \item{object}{an DEGContainer} 22 | 23 | \item{which}{limma edgeR or DESeq2} 24 | 25 | \item{category}{MSigDB collection abbreviation, such as H or C1.} 26 | 27 | \item{gene}{number or gene name} 28 | 29 | \item{light}{number or gene name} 30 | 31 | \item{light_color}{character} 32 | 33 | \item{light_label_color}{character} 34 | 35 | \item{expend}{c(0.12, 0.12)} 36 | 37 | \item{nudge_y_up}{nudge up gene label in y direction} 38 | 39 | \item{nudge_y_down}{nudge down gene label in y direction} 40 | } 41 | \value{ 42 | a ggplot ob 43 | } 44 | \description{ 45 | specific some genes to label 46 | } 47 | \examples{ 48 | PointVolcano(DEGContainer,"limma") 49 | } 50 | -------------------------------------------------------------------------------- /man/ac_.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_check.R 3 | \name{ac_} 4 | \alias{ac_} 5 | \title{add group info for heatmap} 6 | \usage{ 7 | ac_(expr, group_list) 8 | } 9 | \arguments{ 10 | \item{expr}{a expression matrix} 11 | 12 | \item{group_list}{group for samples} 13 | } 14 | \value{ 15 | a data frame for pheatmap annotation 16 | } 17 | \description{ 18 | add group info for heatmap 19 | } 20 | -------------------------------------------------------------------------------- /man/box_check.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/runCheck.R 3 | \name{box_check} 4 | \alias{box_check} 5 | \title{Boxplot of expression matrix} 6 | \usage{ 7 | box_check( 8 | data, 9 | group, 10 | dir = ".", 11 | prefix = "1-run_check", 12 | palette = RColorBrewer::brewer.pal(3, "Set2")[1:2], 13 | ... 14 | ) 15 | } 16 | \arguments{ 17 | \item{data}{a cpm data frame of rows in genes and columns in samples} 18 | 19 | \item{group}{a list ordered by samples in data} 20 | 21 | \item{dir}{a directory to store results} 22 | 23 | \item{prefix}{a prefix of file names in this step} 24 | 25 | \item{palette}{a color palette for plots} 26 | 27 | \item{...}{more parameters in \code{\link{exprBox}}} 28 | } 29 | \value{ 30 | a ridges plot file 31 | } 32 | \description{ 33 | Check data by box plot 34 | } 35 | \examples{ 36 | density_check(data,group) 37 | } 38 | -------------------------------------------------------------------------------- /man/cleanSYMBOL.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{cleanSYMBOL} 4 | \alias{cleanSYMBOL} 5 | \title{Convert a data to SYMBOL named} 6 | \usage{ 7 | cleanSYMBOL(row_counts, bad2good) 8 | } 9 | \arguments{ 10 | \item{row_counts}{count data frame} 11 | 12 | \item{bad2good}{a dataframe, first column should be row name of row_counts, second should be SYMBOL} 13 | } 14 | \value{ 15 | a renamed dataframe 16 | } 17 | \description{ 18 | larger median will be retain for duplicated 19 | } 20 | \examples{ 21 | cleanSYMBOL(count,b2g) 22 | } 23 | -------------------------------------------------------------------------------- /man/commonGroup.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{commonGroup} 4 | \alias{commonGroup} 5 | \title{Title} 6 | \usage{ 7 | commonGroup(merge_data) 8 | } 9 | \arguments{ 10 | \item{merge_data}{} 11 | } 12 | \description{ 13 | Title 14 | } 15 | \examples{ 16 | commonGroup(merge_data) 17 | } 18 | -------------------------------------------------------------------------------- /man/compareEnrichCircle.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_enrichCirclize.R 3 | \name{compareEnrichCircle} 4 | \alias{compareEnrichCircle} 5 | \title{Plot circos of common ID} 6 | \usage{ 7 | compareEnrichCircle( 8 | result_g, 9 | group = "model", 10 | height = 12000, 11 | width = 10000, 12 | mar = c(8, 0, 0, 17), 13 | filename = "circlize_cross.pdf", 14 | IDpalette = as.character(MetBrewer::met.brewer("Signac", length(unique(result_g$ID)))), 15 | heatCircle1 = "Count", 16 | heatCircle2 = "qvalue", 17 | heatCircle1Pal = c("#e5f5e0", "#a1d99b", "#31a354"), 18 | heatCircle2Pal = c("#efedf5", "#bcbddc", "#756bb1"), 19 | groupPal = c("#1f78b4", "#33a02c", "#ff7f00", "#b15928"), 20 | group_name = c("edgeR", "limma", "DESeq2", "merge") 21 | ) 22 | } 23 | \arguments{ 24 | \item{result_g}{results of \code{\link{modelEnrich}} or similar format data} 25 | 26 | \item{group}{which column used to group data} 27 | 28 | \item{height}{height of plot} 29 | 30 | \item{width}{width of plot} 31 | 32 | \item{mar}{margin of bottom, left, top, right around circos} 33 | 34 | \item{filename}{filename} 35 | 36 | \item{IDpalette}{color for unique ID} 37 | 38 | \item{heatCircle1}{which column used to first outer circle} 39 | 40 | \item{heatCircle2}{which column used to second outer circle} 41 | 42 | \item{heatCircle1Pal}{color of first outer circle} 43 | 44 | \item{heatCircle2Pal}{color of second outer circle} 45 | 46 | \item{groupPal}{color for every group} 47 | 48 | \item{group_name}{group name} 49 | } 50 | \value{ 51 | a file store plot 52 | } 53 | \description{ 54 | After a enrich analysis across limma, edgeR, DESeq2 results. How about the distribution among 55 | different datset. 56 | } 57 | \examples{ 58 | compareEnrichCircle(result_g) 59 | } 60 | -------------------------------------------------------------------------------- /man/cor500_check.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/runCheck.R 3 | \name{cor500_check} 4 | \alias{cor500_check} 5 | \title{Correlation of all samples and top 500 genes} 6 | \usage{ 7 | cor500_check( 8 | data, 9 | group, 10 | dir = ".", 11 | prefix = "1-run_check", 12 | palette = RColorBrewer::brewer.pal(3, "Set2")[1:2] 13 | ) 14 | } 15 | \arguments{ 16 | \item{group}{a list ordered by samples in data} 17 | 18 | \item{dir}{a directory to store results} 19 | 20 | \item{prefix}{a prefix of file names in this step} 21 | 22 | \item{palette}{a color palette for plots} 23 | 24 | \item{counts_data}{a counts data frame of rows in genes and columns in samples} 25 | } 26 | \value{ 27 | a Heatmap shows correlation of all samples to 500 genes 28 | } 29 | \description{ 30 | Check data quality by calculating correlation of all samples but top 500 genes 31 | } 32 | \examples{ 33 | cor500_check(counts_input, group) 34 | } 35 | -------------------------------------------------------------------------------- /man/corall_check.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/runCheck.R 3 | \name{corall_check} 4 | \alias{corall_check} 5 | \title{Correlation of all samples and all genes} 6 | \usage{ 7 | corall_check( 8 | data, 9 | group, 10 | dir = ".", 11 | prefix = "1-run_check", 12 | palette = RColorBrewer::brewer.pal(3, "Set2")[1:2] 13 | ) 14 | } 15 | \arguments{ 16 | \item{data}{a cpm data frame of rows in genes and columns in samples} 17 | 18 | \item{group}{a list ordered by samples in data} 19 | 20 | \item{dir}{a directory to store results} 21 | 22 | \item{prefix}{a prefix of file names in this step} 23 | 24 | \item{palette}{a color palette for plots} 25 | } 26 | \value{ 27 | a Heatmap shows correlation of all samples 28 | } 29 | \description{ 30 | Check data quality by calculating correlation of all samples 31 | } 32 | \examples{ 33 | corall_check(data, group) 34 | } 35 | -------------------------------------------------------------------------------- /man/cutFC_Verify.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{cutFC_Verify} 4 | \alias{cutFC_Verify} 5 | \title{Verify the rationality of the FC threshold} 6 | \usage{ 7 | cutFC_Verify(res, cut_FC, scale = 1) 8 | } 9 | \arguments{ 10 | \item{res}{one of result from limma or DESeq2 or edgeR} 11 | 12 | \item{cut_FC}{if is null, will give a recommend value.} 13 | 14 | \item{scale}{adjust recommend value} 15 | } 16 | \value{ 17 | a value 18 | } 19 | \description{ 20 | Verify the rationality of the FC threshold 21 | } 22 | \examples{ 23 | cutFC_Verify(deg_data) 24 | } 25 | -------------------------------------------------------------------------------- /man/cutMuch.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{cutMuch} 4 | \alias{cutMuch} 5 | \title{Group result of DEG analysis results} 6 | \usage{ 7 | cutMuch(object, which, category = "H") 8 | } 9 | \arguments{ 10 | \item{object}{a DEGContainer} 11 | 12 | \item{which}{kinds of DEG; can be "limma", "edgeR", "DESeq2" or "MSigDB"} 13 | 14 | \item{category}{MSigDB collection abbreviation, such as H or C1.} 15 | } 16 | \value{ 17 | a DEGContainer 18 | } 19 | \description{ 20 | Group result of DEG analysis results 21 | } 22 | \examples{ 23 | cutMuch(DEGContainer,"limma","H") 24 | } 25 | -------------------------------------------------------------------------------- /man/dataDEG.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{dataDEG} 4 | \alias{dataDEG} 5 | \title{get deg data of DEGContainer} 6 | \usage{ 7 | dataDEG(obj, which, category = "H") 8 | } 9 | \arguments{ 10 | \item{obj}{a DEGContainer object} 11 | 12 | \item{which}{kinds of DEG; can be "limma", "edgeR", "DESeq2" or "MSigDB"} 13 | 14 | \item{category}{MSigDB collection abbreviation, such as H or C1.} 15 | } 16 | \value{ 17 | a dataframe 18 | } 19 | \description{ 20 | get deg data of DEGContainer 21 | } 22 | \examples{ 23 | dataDEG(DEGContainer) 24 | } 25 | -------------------------------------------------------------------------------- /man/dataInfo.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/allClass.R, R/allGeneric.R 3 | \docType{methods} 4 | \name{dataInfo} 5 | \alias{dataInfo} 6 | \alias{dataInfo-class} 7 | \alias{treatInfo-class} 8 | \alias{species} 9 | \alias{dataType} 10 | \alias{idType} 11 | \alias{expMatrix} 12 | \alias{groupInfo} 13 | \alias{caseGroup} 14 | \alias{filterMethod} 15 | \alias{matrixFiltered} 16 | \alias{geneNames} 17 | \alias{sampleNames} 18 | \alias{species<-} 19 | \alias{dataType<-} 20 | \alias{idType<-} 21 | \alias{expMatrix<-} 22 | \alias{groupInfo<-} 23 | \alias{caseGroup<-} 24 | \alias{filterMethod<-} 25 | \alias{matrixFiltered<-} 26 | \alias{geneNames<-} 27 | \alias{sampleNames<-} 28 | \title{Class \code{dataInfo}} 29 | \usage{ 30 | species(obj) 31 | 32 | dataType(obj) 33 | 34 | idType(obj) 35 | 36 | expMatrix(obj) 37 | 38 | groupInfo(obj) 39 | 40 | caseGroup(obj) 41 | 42 | filterMethod(obj) 43 | 44 | matrixFiltered(obj) 45 | 46 | geneNames(obj, filtered) 47 | 48 | sampleNames(obj, filtered) 49 | 50 | species(obj) <- value 51 | 52 | dataType(obj) <- value 53 | 54 | idType(obj) <- value 55 | 56 | expMatrix(obj) <- value 57 | 58 | groupInfo(obj) <- value 59 | 60 | caseGroup(obj) <- value 61 | 62 | filterMethod(obj) <- value 63 | 64 | matrixFiltered(obj) <- value 65 | 66 | geneNames(obj, filtered) <- value 67 | 68 | sampleNames(obj, filtered) <- value 69 | } 70 | \value{ 71 | The accessor functions \code{species}, \code{dataType}, \cr 72 | \code{idType}, \code{expMatrix}, \code{groupInfo}, \cr 73 | \code{caseGroup}, \code{filterMethod}, \code{matrixFiltered} \cr 74 | return the corresponding elements of a \cr 75 | \code{DEGContainer} or \code{dataInfo}. \cr 76 | } 77 | \description{ 78 | This was the class for storing input data for workflow. 79 | We now generally recommend using the \code{\link{Create_DEGContainer}} 80 | to create it in \code{DEGContainer} obj. 81 | 82 | contains configurations info of RNAseqStat2 83 | } 84 | \section{Slots}{ 85 | 86 | \describe{ 87 | \item{\code{species}}{species for your data. `Human` or `Mouse`.} 88 | 89 | \item{\code{dataType}}{kind of expresses value matrix. `Counts` (Integer) or `Array` (Decimal).} 90 | 91 | \item{\code{idType}}{kind of gene id. `ENSEMBL` or `SYMBOL`, If `ENSEMBL`, it will be automatically converted to `SYMBOL`.} 92 | 93 | \item{\code{expMatrix}}{expresses value matrix. Should be a data.frame row named by gene ID and column named by Sample} 94 | 95 | \item{\code{groupInfo}}{a Character Vectors ordered by samples in matrix.} 96 | 97 | \item{\code{caseGroup}}{a Character names of case group.} 98 | 99 | \item{\code{filterMethod}}{a function used to filter expresses value matrix. Or disable filter by set as `NULL`.} 100 | 101 | \item{\code{matrixFiltered}}{expresses value matrix after apply \code{filterMethod}. Should be a data.frame row named by gene ID and column named by Sample} 102 | }} 103 | 104 | \seealso{ 105 | Other DEGContainer: 106 | \code{\link{MSigDB}}, 107 | \code{\link{degResults-class}} 108 | 109 | Other DEGContainer: 110 | \code{\link{MSigDB}}, 111 | \code{\link{degResults-class}} 112 | } 113 | \concept{DEGContainer} 114 | -------------------------------------------------------------------------------- /man/degGroup.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/degGroup.R 3 | \name{degGroup} 4 | \alias{degGroup} 5 | \title{Group degResults} 6 | \usage{ 7 | degGroup(obj) 8 | } 9 | \arguments{ 10 | \item{obj}{a DEGContainer} 11 | } 12 | \value{ 13 | a DEGContainer 14 | } 15 | \description{ 16 | group results of DEG analysis 17 | } 18 | \examples{ 19 | degGroup(DEGContainer) 20 | } 21 | -------------------------------------------------------------------------------- /man/degResolve.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/degResolve.R 3 | \name{degResolve} 4 | \alias{degResolve} 5 | \title{run DEG minimal} 6 | \usage{ 7 | degResolve(object, dir = ".", prefix = "2-DEG", parallel = FALSE, qc = TRUE) 8 | } 9 | \arguments{ 10 | \item{object}{a DEGContainer contains at least dataInfo} 11 | 12 | \item{dir}{a directory to store results} 13 | 14 | \item{parallel}{if FALSE, no parallelization. if TRUE, parallel execution using BiocParallel} 15 | } 16 | \value{ 17 | a csv file and a DEG_container ob 18 | } 19 | \description{ 20 | run DEG module in limma, DESeq2 and edgeR 21 | } 22 | \examples{ 23 | \dontrun{ 24 | degResolve(counts_input,group_list,case_group = "T", control_group = "C",dir = tempdir()) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /man/degResolveArray.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/degResolveArray.R 3 | \name{degResolveArray} 4 | \alias{degResolveArray} 5 | \title{run DEG minimal} 6 | \usage{ 7 | degResolveArray(object, dir = ".", prefix = "2-DEG") 8 | } 9 | \arguments{ 10 | \item{object}{a DEGContainer contains at least dataInfo} 11 | 12 | \item{dir}{a directory to store results} 13 | 14 | \item{parallel}{if FALSE, no parallelization. if TRUE, parallel execution using BiocParallel} 15 | } 16 | \value{ 17 | a csv file and a DEG_container ob 18 | } 19 | \description{ 20 | run DEG module in limma, DESeq2 and edgeR 21 | } 22 | \examples{ 23 | \dontrun{ 24 | degResolve(counts_input,group_list,case_group = "T", control_group = "C",dir = tempdir()) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /man/degResults.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/allClass.R 3 | \docType{class} 4 | \name{degResults-class} 5 | \alias{degResults-class} 6 | \title{a S4 class contains degResults from deg analysis} 7 | \description{ 8 | contains deg analysis results in RNAseqStat2 9 | } 10 | \seealso{ 11 | Other DEGContainer: 12 | \code{\link{MSigDB}}, 13 | \code{\link{dataInfo}} 14 | } 15 | \concept{DEGContainer} 16 | -------------------------------------------------------------------------------- /man/degSummary.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/degSummary.R 3 | \name{degSummary} 4 | \alias{degSummary} 5 | \title{Summary results of DEG analysis} 6 | \usage{ 7 | degSummary( 8 | obj, 9 | dir = ".", 10 | prefix = "2-runDEG", 11 | PointVolcanoParam = list(gene = 10, light = NULL, light_color = "#24ac56", 12 | light_label_color = "#24ac56", expend = c(0.12, 0.12)) 13 | ) 14 | } 15 | \arguments{ 16 | \item{obj}{a DEGContainer object} 17 | 18 | \item{dir}{a directory to store results} 19 | 20 | \item{prefix}{a prefix of file names in this step} 21 | 22 | \item{PointVolcanoParam}{more parameters for \code{\link{PointVolcano}}} 23 | } 24 | \value{ 25 | a batch of files 26 | } 27 | \description{ 28 | Summary results of DEG analysis 29 | } 30 | \examples{ 31 | degSummary(DEGContainer) 32 | } 33 | -------------------------------------------------------------------------------- /man/deg_here.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{deg_here} 4 | \alias{deg_here} 5 | \title{Test for exists of DEG results} 6 | \usage{ 7 | deg_here(object) 8 | } 9 | \arguments{ 10 | \item{object}{a DEGContainer} 11 | } 12 | \value{ 13 | logic vector 14 | } 15 | \description{ 16 | Test for exists of DEG results 17 | } 18 | \examples{ 19 | deg_here(DEGContainer) 20 | } 21 | -------------------------------------------------------------------------------- /man/density_check.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/runCheck.R 3 | \name{density_check} 4 | \alias{density_check} 5 | \title{Density of expression matrix} 6 | \usage{ 7 | density_check( 8 | data, 9 | group, 10 | dir = ".", 11 | prefix = "1-run_check", 12 | palette = RColorBrewer::brewer.pal(3, "Set2")[1:2], 13 | ... 14 | ) 15 | } 16 | \arguments{ 17 | \item{data}{a cpm data frame of rows in genes and columns in samples} 18 | 19 | \item{group}{a list ordered by samples in data} 20 | 21 | \item{dir}{a directory to store results} 22 | 23 | \item{prefix}{a prefix of file names in this step} 24 | 25 | \item{palette}{a color palette for plots} 26 | 27 | \item{...}{more parameters in \code{\link{exprRidges}}} 28 | } 29 | \value{ 30 | a ridges plot file 31 | } 32 | \description{ 33 | Check data density by ridges plot 34 | } 35 | \examples{ 36 | density_check(data,group) 37 | } 38 | -------------------------------------------------------------------------------- /man/edgeR_resolve.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/degResolve.R 3 | \name{edgeR_resolve} 4 | \alias{edgeR_resolve} 5 | \title{Basic produce of edgeR} 6 | \usage{ 7 | edgeR_resolve(counts_data, group_list, control_group) 8 | } 9 | \arguments{ 10 | \item{counts_data}{a counts data frame of rows in genes and columns in samples} 11 | 12 | \item{group_list}{a character vector ordered by samples in counts_data} 13 | 14 | \item{control_group}{the name of the denominator level for the fold change (Control group)} 15 | } 16 | \value{ 17 | a DEG data frame 18 | } 19 | \description{ 20 | A basic function to get data and produce results of edgeR 21 | } 22 | \examples{ 23 | edgeR_resolve_(counts_input, group_list, control_group= "C") 24 | } 25 | -------------------------------------------------------------------------------- /man/eggnogG2T.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{eggnogG2T} 4 | \alias{eggnogG2T} 5 | \title{Convert EGGnog to GENE2TERM} 6 | \usage{ 7 | eggnogG2T(data, SYMBOL, TERM) 8 | } 9 | \arguments{ 10 | \item{data}{data from eggnog} 11 | 12 | \item{SYMBOL}{which column is SYMBOL} 13 | 14 | \item{TERM}{which column is Pathway} 15 | } 16 | \value{ 17 | a data frame 18 | } 19 | \description{ 20 | Convert EGGnog to GENE2TERM 21 | } 22 | \examples{ 23 | eggnogG2T(data,SYMBOL,TERM) 24 | } 25 | -------------------------------------------------------------------------------- /man/enrichBar.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_enrichBar.R 3 | \name{enrichBar} 4 | \alias{enrichBar} 5 | \title{enrich bar plot} 6 | \usage{ 7 | enrichBar( 8 | enrichResult, 9 | top = 10, 10 | group = "ONTOLOGY", 11 | space = 0.9, 12 | order_by = "pvalue", 13 | FDR = "qvalue", 14 | bar = "logP", 15 | bar_size = 2, 16 | point = "gr", 17 | point_shape = 21, 18 | point_size = 2.5, 19 | point_color = c("#de2d26", "#fc9272", "#fee0d2"), 20 | bar_color = rev(RColorBrewer::brewer.pal(5, "GnBu")[3:5]), 21 | group_color = RColorBrewer::brewer.pal(3, "Dark2"), 22 | group_names = c("Biological Process", "Cellular Component", "Molecular Function"), 23 | group_color_name = c("BP", "CC", "MF"), 24 | group_title = "ONTOLOGY", 25 | bar_title = "Qvalue", 26 | point_title = "GeneRatio", 27 | x_title = "-log10(pvalue)", 28 | y_title = "Description", 29 | plot_title = NULL, 30 | legend_text_size = 12, 31 | FDR_color = c("#de2d26", "#fc9272", "#fee0d2") 32 | ) 33 | } 34 | \arguments{ 35 | \item{enrichResult}{a \code{\link[DOSE]{enrichResult}}} 36 | 37 | \item{top}{number of top categories to show} 38 | 39 | \item{group}{which column used to split group} 40 | 41 | \item{space}{space for text} 42 | 43 | \item{order_by}{order by which column, default is pvalue} 44 | 45 | \item{FDR}{pvalue or qvalue} 46 | 47 | \item{bar}{which column to plot bar, default is 'logP'} 48 | 49 | \item{bar_size}{size of bar} 50 | 51 | \item{point}{which column to plot point, default is 'gr'} 52 | 53 | \item{point_shape}{shape of point} 54 | 55 | \item{point_size}{size of point} 56 | 57 | \item{point_color}{color of point} 58 | 59 | \item{bar_color}{color of bar} 60 | 61 | \item{group_color}{color of group} 62 | 63 | \item{group_names}{label of group} 64 | 65 | \item{group_color_name}{color label of group} 66 | 67 | \item{group_title}{title label of group} 68 | 69 | \item{bar_title}{title of bar} 70 | 71 | \item{point_title}{title of point} 72 | 73 | \item{x_title}{title of x axis} 74 | 75 | \item{y_title}{title of y axis} 76 | 77 | \item{plot_title}{title of point} 78 | 79 | \item{legend_text_size}{size of legend text} 80 | 81 | \item{FDR_color}{color of FDR} 82 | } 83 | \value{ 84 | a ggplot 85 | } 86 | \description{ 87 | enrich bar plot 88 | } 89 | \examples{ 90 | enrichBar(enrichResult) 91 | } 92 | -------------------------------------------------------------------------------- /man/enrichGO2.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils-go.R 3 | \name{enrichGO2} 4 | \alias{enrichGO2} 5 | \title{GO Enrichment Analysis of a gene set.} 6 | \usage{ 7 | enrichGO2( 8 | gene, 9 | TERM2GENE, 10 | TERM2NAME = NA, 11 | organism = "UNKNOW", 12 | keyType = "SYMBOL", 13 | ont = "ALL", 14 | pvalueCutoff = 0.05, 15 | pAdjustMethod = "BH", 16 | universe, 17 | qvalueCutoff = 0.2, 18 | minGSSize = 10, 19 | maxGSSize = 500, 20 | pool = FALSE 21 | ) 22 | } 23 | \arguments{ 24 | \item{gene}{a vector of entrez gene id.} 25 | 26 | \item{TERM2GENE}{user input annotation of TERM TO GENE mapping, a data.frame of 2 column with term and gene} 27 | 28 | \item{TERM2NAME}{user input of TERM TO NAME mapping, a data.frame of 2 column with term and name} 29 | 30 | \item{keyType}{keytype of input gene} 31 | 32 | \item{ont}{One of "BP", "MF", and "CC" subontologies, or "ALL" for all three.} 33 | 34 | \item{pvalueCutoff}{adjusted pvalue cutoff on enrichment tests to report} 35 | 36 | \item{pAdjustMethod}{one of "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none"} 37 | 38 | \item{universe}{background genes. If missing, the all genes listed in the database (eg TERM2GENE table) will be used as background.} 39 | 40 | \item{qvalueCutoff}{qvalue cutoff on enrichment tests to report as significant. Tests must pass i) \code{pvalueCutoff} on unadjusted pvalues, ii) \code{pvalueCutoff} on adjusted pvalues and iii) \code{qvalueCutoff} on qvalues to be reported.} 41 | 42 | \item{minGSSize}{minimal size of genes annotated by Ontology term for testing.} 43 | 44 | \item{maxGSSize}{maximal size of genes annotated for testing} 45 | 46 | \item{pool}{If ont='ALL', whether pool 3 GO sub-ontologies} 47 | } 48 | \value{ 49 | An \code{enrichResult} instance. 50 | } 51 | \description{ 52 | Given a vector of genes, this function will return the enrichment GO 53 | categories after FDR control. \code{\link[clusterProfiler]{enrichGO}} only support OrgDb and 54 | \code{\link[clusterProfiler]{enricher}} is too simple for GO. 55 | In this case, a modified version of enrichGO here 56 | } 57 | \examples{ 58 | \dontrun{ 59 | enrichGO2(gene,TERM2GENE,TERM2NAME) 60 | } 61 | } 62 | \keyword{manip} 63 | -------------------------------------------------------------------------------- /man/exprBox.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_check.R 3 | \name{exprBox} 4 | \alias{exprBox} 5 | \title{Boxplot of all samples} 6 | \usage{ 7 | exprBox( 8 | expr, 9 | group_list, 10 | palette = RColorBrewer::brewer.pal(3, "Set2")[1:2], 11 | main = "Boxplot of all samples", 12 | filename = NA, 13 | x = "Samples", 14 | y = "log2(cpm(count)+1)", 15 | height = 4.46, 16 | width = 8.3 17 | ) 18 | } 19 | \arguments{ 20 | \item{expr}{a expression matrix} 21 | 22 | \item{group_list}{a character vector order by samples} 23 | 24 | \item{palette}{group palette} 25 | 26 | \item{main}{plot title} 27 | 28 | \item{filename}{file name you want to save plot} 29 | 30 | \item{x}{x axis title} 31 | 32 | \item{y}{y axis title} 33 | 34 | \item{height}{height of plot} 35 | 36 | \item{width}{width of plot} 37 | } 38 | \description{ 39 | plot a boxplot of all samples 40 | } 41 | \examples{ 42 | exprBox(counts_input,group_list=group_list) 43 | } 44 | -------------------------------------------------------------------------------- /man/exprCorHeatmap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_check.R 3 | \name{exprCorHeatmap} 4 | \alias{exprCorHeatmap} 5 | \title{Correlation Heatmap between samples} 6 | \usage{ 7 | exprCorHeatmap( 8 | expr, 9 | group_list, 10 | filename = NA, 11 | top = NA, 12 | main = "Correlation by all genes", 13 | palette = RColorBrewer::brewer.pal(3, "Set2")[1:2], 14 | anno_title = "Group", 15 | annotation_col = ac_(expr, group_list), 16 | width = ncol(expr) * 0.3 + 2.2, 17 | height = ncol(expr) * 0.3 + 2.2, 18 | ..., 19 | heatmapParam = list(show_rownames = F) 20 | ) 21 | } 22 | \arguments{ 23 | \item{expr}{a expression matrix} 24 | 25 | \item{group_list}{a character vector order by samples} 26 | 27 | \item{filename}{file name you want to save plot} 28 | 29 | \item{top}{if not NA, only keep top of genes by mad} 30 | 31 | \item{main}{plot title} 32 | 33 | \item{palette}{annotation palette} 34 | 35 | \item{anno_title}{annotation title} 36 | 37 | \item{annotation_col}{annotation dataframe} 38 | 39 | \item{width}{width of plot} 40 | 41 | \item{height}{height of plot} 42 | 43 | \item{...}{more parameters in \code{\link[pheatmap]{pheatmap}}} 44 | 45 | \item{heatmapParam}{more parameters in \code{\link[pheatmap]{pheatmap}}} 46 | } 47 | \value{ 48 | a heatmap plot or a file 49 | } 50 | \description{ 51 | plot a heatmap of correlation between samples 52 | } 53 | \details{ 54 | Use \code{\link[stats]{cor}} to get correlation of samples. Can filter genes by `top`. 55 | `top` means the top mad (by \code{\link[stats]{mad}}) of expression matrix. 56 | } 57 | \examples{ 58 | exprCorHeatmap(expr,group_list) 59 | } 60 | -------------------------------------------------------------------------------- /man/exprHKGheatmap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_check.R 3 | \name{exprHKGheatmap} 4 | \alias{exprHKGheatmap} 5 | \title{Human housekeeping genes Heatmap} 6 | \usage{ 7 | exprHKGheatmap( 8 | expr, 9 | group_list, 10 | filename = NA, 11 | main = "Human housekeeping genes", 12 | hk = c("C1orf43", "CHMP2A", "EMC7", "GPI", "PSMB2", "PSMB4", "RAB7A", "REEP5", 13 | "SNRPD3", "VCP", "VPS29"), 14 | palette = RColorBrewer::brewer.pal(3, "Set2")[1:2], 15 | anno_title = "Group", 16 | annotation_col = ac_(expr, group_list), 17 | width = ncol(expr) * 0.3 + 2.2, 18 | height = 10 * 0.3 + 2.2, 19 | ..., 20 | heatmapParam = list(show_rownames = T, cluster_cols = F) 21 | ) 22 | } 23 | \arguments{ 24 | \item{expr}{a expression matrix} 25 | 26 | \item{group_list}{a character vector order by samples} 27 | 28 | \item{filename}{file name you want to save plot} 29 | 30 | \item{main}{plot title} 31 | 32 | \item{hk}{strongly expressed genes} 33 | 34 | \item{palette}{annotation palette} 35 | 36 | \item{anno_title}{annotation title} 37 | 38 | \item{annotation_col}{annotation dataframe} 39 | 40 | \item{width}{width of plot} 41 | 42 | \item{height}{height of plot} 43 | 44 | \item{...}{more parameters in \code{\link[pheatmap]{pheatmap}}} 45 | 46 | \item{heatmapParam}{more parameters in \code{\link[pheatmap]{pheatmap}}} 47 | 48 | \item{top}{if not NA, only keep top of genes by mad} 49 | } 50 | \value{ 51 | a heatmap or a file 52 | } 53 | \description{ 54 | plot a heatmap of highly uniform and strongly expressed Human housekeeping genes 55 | } 56 | \details{ 57 | Human housekeeping genes revisited in \cr 58 | https://www.tau.ac.il/~elieis/HKG/ \cr 59 | E. Eisenberg and E.Y. Levanon, Trends in Genetics, 29 (2013) \cr 60 | } 61 | \examples{ 62 | exprHKGheatmap(expr,group_list) 63 | } 64 | -------------------------------------------------------------------------------- /man/exprPCA.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_check.R 3 | \name{exprPCA} 4 | \alias{exprPCA} 5 | \title{PCA plot for Grouped Samples} 6 | \usage{ 7 | exprPCA( 8 | expr, 9 | group_list, 10 | palette = RColorBrewer::brewer.pal(3, "Set2")[1:2], 11 | filename = NA, 12 | main = "all samples - PCA", 13 | width = 3.5, 14 | height = 4, 15 | ... 16 | ) 17 | } 18 | \arguments{ 19 | \item{expr}{a expression matrix} 20 | 21 | \item{group_list}{a character vector order by samples} 22 | 23 | \item{palette}{group palette} 24 | 25 | \item{filename}{file name you want to save plot} 26 | 27 | \item{main}{plot title} 28 | 29 | \item{width}{width of plot} 30 | 31 | \item{height}{height of plot} 32 | 33 | \item{...}{more parameters in \code{\link[factoextra]{fviz_pca_ind}}} 34 | } 35 | \value{ 36 | a PCA plot or a file 37 | } 38 | \description{ 39 | plot a pca for expression matrix 40 | } 41 | \details{ 42 | Use \code{\link[FactoMineR]{PCA}} to get PCA of grouped samples. 43 | } 44 | \examples{ 45 | exprPCA(expr,group_list) 46 | } 47 | -------------------------------------------------------------------------------- /man/exprRidges.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_check.R 3 | \name{exprRidges} 4 | \alias{exprRidges} 5 | \title{Ridges plot of all samples} 6 | \usage{ 7 | exprRidges( 8 | expr, 9 | group_list, 10 | palette = RColorBrewer::brewer.pal(3, "Set2")[1:2], 11 | main = "Density of gene expression", 12 | filename = NA, 13 | x = "Samples", 14 | y = "log2(cpm(count)+1)", 15 | height = 5, 16 | width = 8.3 17 | ) 18 | } 19 | \arguments{ 20 | \item{expr}{a expression matrix} 21 | 22 | \item{group_list}{a character vector order by samples} 23 | 24 | \item{palette}{group palette} 25 | 26 | \item{main}{plot title} 27 | 28 | \item{filename}{file name you want to save plot} 29 | 30 | \item{x}{x axis title} 31 | 32 | \item{y}{y axis title} 33 | 34 | \item{height}{height of plot} 35 | 36 | \item{width}{width of plot} 37 | } 38 | \value{ 39 | a Ridges plot or a file 40 | } 41 | \description{ 42 | Ridges plot of all samples 43 | } 44 | \examples{ 45 | exprRidges(expr,group_list) 46 | } 47 | -------------------------------------------------------------------------------- /man/exprTopHeatmap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_check.R 3 | \name{exprTopHeatmap} 4 | \alias{exprTopHeatmap} 5 | \title{Expression Heatmap} 6 | \usage{ 7 | exprTopHeatmap( 8 | expr, 9 | group_list, 10 | filename = NA, 11 | top = 1000, 12 | main = "SD Top 1000 genes", 13 | palette = RColorBrewer::brewer.pal(3, "Set2")[1:2], 14 | anno_title = "Group", 15 | annotation_col = ac_(expr, group_list), 16 | width = ncol(expr) * 0.3 + 2.2, 17 | height = ncol(expr) * 0.3 + 2.2, 18 | ..., 19 | heatmapParam = list(show_rownames = F) 20 | ) 21 | } 22 | \arguments{ 23 | \item{expr}{a expression matrix} 24 | 25 | \item{group_list}{a character vector order by samples} 26 | 27 | \item{filename}{file name you want to save plot} 28 | 29 | \item{top}{if not NA, only keep top of genes by mad} 30 | 31 | \item{main}{plot title} 32 | 33 | \item{palette}{annotation palette} 34 | 35 | \item{anno_title}{annotation title} 36 | 37 | \item{annotation_col}{annotation dataframe} 38 | 39 | \item{width}{width of plot} 40 | 41 | \item{height}{height of plot} 42 | 43 | \item{...}{more parameters in \code{\link[pheatmap]{pheatmap}}} 44 | 45 | \item{heatmapParam}{more parameters in \code{\link[pheatmap]{pheatmap}}} 46 | } 47 | \value{ 48 | a heatmap or a file 49 | } 50 | \description{ 51 | plot a heatmap of expression matrix 52 | } 53 | \details{ 54 | Can filter genes by `top`. 55 | `top` means the top sd (by \code{\link[stats]{sd}}) of expression matrix. 56 | } 57 | \examples{ 58 | exprTopHeatmap(expr,group_list) 59 | } 60 | -------------------------------------------------------------------------------- /man/geom_volcano_point.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_DEGvolcano.R 3 | \name{geom_volcano_point} 4 | \alias{geom_volcano_point} 5 | \title{A preset geom of \code{\link[ggplot2]{geom_point}}} 6 | \usage{ 7 | geom_volcano_point( 8 | data, 9 | shape = 1, 10 | stroke = 0.15, 11 | color = "#24ac56", 12 | fill = NA, 13 | ..., 14 | mapping = NULL 15 | ) 16 | } 17 | \value{ 18 | geom 19 | } 20 | \description{ 21 | A preset geom of \code{\link[ggplot2]{geom_point}} 22 | } 23 | -------------------------------------------------------------------------------- /man/geom_volcano_text.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_DEGvolcano.R 3 | \name{geom_volcano_text} 4 | \alias{geom_volcano_text} 5 | \title{A preset geom of \code{\link[ggrepel]{geom_text_repel}}} 6 | \usage{ 7 | geom_volcano_text( 8 | data, 9 | mapping = NULL, 10 | nudge_x = NULL, 11 | nudge_y = -1, 12 | hjust = 0, 13 | size = 1.8, 14 | direction = "y", 15 | segment.size = 0.1, 16 | segment.linetype = 6, 17 | max.overlaps = 10, 18 | max.iter = 1e+06, 19 | max.time = 10, 20 | min.segment.length = 0, 21 | fontface = "bold", 22 | family = "Times", 23 | ... 24 | ) 25 | } 26 | \value{ 27 | geom 28 | } 29 | \description{ 30 | A preset geom of \code{\link[ggrepel]{geom_text_repel}} 31 | } 32 | -------------------------------------------------------------------------------- /man/get_breaks.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_DEGvolcano.R 3 | \name{get_breaks} 4 | \alias{get_breaks} 5 | \title{Values break parameters \code{\link[ggplot2]{scale_colour_identity}}} 6 | \usage{ 7 | get_breaks(volcano, column_name) 8 | } 9 | \arguments{ 10 | \item{volcano}{data from \code{\link{create_volcano}}} 11 | 12 | \item{column_name}{a column name, e.g. "point.color"} 13 | } 14 | \value{ 15 | Values for break parameters 16 | } 17 | \description{ 18 | Values break parameters \code{\link[ggplot2]{scale_colour_identity}} 19 | } 20 | -------------------------------------------------------------------------------- /man/groupCir.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_enrichCirclize.R 3 | \name{groupCir} 4 | \alias{groupCir} 5 | \title{Group circlize matrix} 6 | \usage{ 7 | groupCir(matrix) 8 | } 9 | \arguments{ 10 | \item{matrix}{row names is from, column names is to} 11 | } 12 | \value{ 13 | a named character vector 14 | } 15 | \description{ 16 | Group circlize matrix 17 | } 18 | \examples{ 19 | groupCir(matrix) 20 | } 21 | -------------------------------------------------------------------------------- /man/gseGO2.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils-go.R 3 | \name{gseGO2} 4 | \alias{gseGO2} 5 | \title{gseGO2} 6 | \usage{ 7 | gseGO2( 8 | geneList, 9 | ont = "ALL", 10 | TERM2GENE, 11 | TERM2NAME = NA, 12 | organism = "UNKNOW", 13 | keyType = "SYMBOL", 14 | exponent = 1, 15 | minGSSize = 10, 16 | maxGSSize = 500, 17 | eps = 1e-10, 18 | pvalueCutoff = 0.05, 19 | pAdjustMethod = "BH", 20 | verbose = TRUE, 21 | seed = FALSE, 22 | by = "fgsea", 23 | ... 24 | ) 25 | } 26 | \arguments{ 27 | \item{geneList}{order ranked geneList} 28 | 29 | \item{ont}{one of "BP", "MF", and "CC" subontologies, or "ALL" for all three.} 30 | 31 | \item{keyType}{keytype of gene} 32 | 33 | \item{exponent}{weight of each step} 34 | 35 | \item{minGSSize}{minimal size of each geneSet for analyzing} 36 | 37 | \item{maxGSSize}{maximal size of genes annotated for testing} 38 | 39 | \item{eps}{This parameter sets the boundary for calculating the p value.} 40 | 41 | \item{pvalueCutoff}{pvalue Cutoff} 42 | 43 | \item{pAdjustMethod}{pvalue adjustment method} 44 | 45 | \item{verbose}{print message or not} 46 | 47 | \item{seed}{logical} 48 | 49 | \item{by}{one of 'fgsea' or 'DOSE'} 50 | 51 | \item{...}{other parameter} 52 | } 53 | \value{ 54 | gseaResult object 55 | } 56 | \description{ 57 | Gene Set Enrichment Analysis of Gene Ontology 58 | } 59 | -------------------------------------------------------------------------------- /man/gseMSigDB.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/msigdbResolve.R 3 | \name{gseMSigDB} 4 | \alias{gseMSigDB} 5 | \title{GSE analysis of MSigDB data sets} 6 | \usage{ 7 | gseMSigDB(object) 8 | } 9 | \arguments{ 10 | \item{object}{a DEGContainer} 11 | } 12 | \value{ 13 | a DEGContainer 14 | } 15 | \description{ 16 | GSE analysis of MSigDB data sets 17 | } 18 | \examples{ 19 | gseMSigDB(DEGContainer) 20 | } 21 | -------------------------------------------------------------------------------- /man/gseResolve.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/gseResolve.R 3 | \name{gseResolve} 4 | \alias{gseResolve} 5 | \title{GSEA analysis} 6 | \usage{ 7 | gseResolve(object, GO = FALSE, KEGG = TRUE) 8 | } 9 | \arguments{ 10 | \item{object}{a DEGContainer} 11 | 12 | \item{GO}{run GO database} 13 | 14 | \item{KEGG}{run KEGG database} 15 | } 16 | \value{ 17 | a DEGContainer 18 | } 19 | \description{ 20 | GSEA analysis 21 | } 22 | \examples{ 23 | gseResolve(DEGContainer) 24 | } 25 | -------------------------------------------------------------------------------- /man/gseSummary.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/gseSummary.R 3 | \name{gseSummary} 4 | \alias{gseSummary} 5 | \title{Summary GSE results} 6 | \usage{ 7 | gseSummary(obj, dir = ".", prefix = "4-runGSEA", top = 10) 8 | } 9 | \arguments{ 10 | \item{obj}{a DEGContainer} 11 | 12 | \item{dir}{a directory to store results} 13 | 14 | \item{prefix}{a prefix of file names in this step} 15 | 16 | \item{top}{top rows of up and down} 17 | } 18 | \value{ 19 | files 20 | } 21 | \description{ 22 | Summary GSE results 23 | } 24 | \examples{ 25 | gseSummary(DEGContainer) 26 | } 27 | -------------------------------------------------------------------------------- /man/gsvaResolve.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/msigdbResolve.R 3 | \name{gsvaResolve} 4 | \alias{gsvaResolve} 5 | \title{GSVA analysis} 6 | \usage{ 7 | gsvaResolve(object) 8 | } 9 | \arguments{ 10 | \item{object}{a DEGContainer} 11 | } 12 | \description{ 13 | GSVA analysis 14 | } 15 | \examples{ 16 | gsvaResolve(DEGContainer) 17 | } 18 | -------------------------------------------------------------------------------- /man/heatCir.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_enrichCirclize.R 3 | \name{heatCir} 4 | \alias{heatCir} 5 | \title{heatmap values for annotation circlize} 6 | \usage{ 7 | heatCir(matrix, df, look = "Count") 8 | } 9 | \arguments{ 10 | \item{matrix}{row names is from, column names is to} 11 | 12 | \item{df}{a data frame contains multigroup results of enrich} 13 | 14 | \item{look}{which column as heatmap value} 15 | } 16 | \value{ 17 | a list for heatmap in circlize 18 | } 19 | \description{ 20 | heatmap values for annotation circlize 21 | } 22 | \examples{ 23 | heatCir(matrix,df) 24 | } 25 | -------------------------------------------------------------------------------- /man/heatLegend.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_enrichCirclize.R 3 | \name{heatLegend} 4 | \alias{heatLegend} 5 | \title{Legend for heatmap} 6 | \usage{ 7 | heatLegend( 8 | annoData, 9 | palatte, 10 | ..., 11 | title = "Values", 12 | title_position = "topleft", 13 | int = T 14 | ) 15 | } 16 | \arguments{ 17 | \item{annoData}{a} 18 | 19 | \item{palatte}{p} 20 | 21 | \item{...}{more Legend parameters} 22 | 23 | \item{title}{t} 24 | 25 | \item{title_position}{t} 26 | 27 | \item{int}{integer value?} 28 | } 29 | \value{ 30 | a legend of circlize 31 | } 32 | \description{ 33 | Legend for heatmap 34 | } 35 | \examples{ 36 | heatLegend(annoData, palatte) 37 | } 38 | -------------------------------------------------------------------------------- /man/highlightGroup.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_enrichCirclize.R 3 | \name{highlightGroup} 4 | \alias{highlightGroup} 5 | \title{Group highlight} 6 | \usage{ 7 | highlightGroup( 8 | df, 9 | track.index = 1, 10 | palatte, 11 | cex = 1, 12 | text.col = "white", 13 | niceFacing = TRUE, 14 | text.vjust = "4mm", 15 | ... 16 | ) 17 | } 18 | \arguments{ 19 | \item{df}{d} 20 | 21 | \item{track.index}{t} 22 | 23 | \item{palatte}{p} 24 | 25 | \item{cex}{c} 26 | 27 | \item{text.col}{t} 28 | 29 | \item{niceFacing}{f} 30 | 31 | \item{text.vjust}{t} 32 | 33 | \item{...}{more highlight.sector parameters} 34 | } 35 | \value{ 36 | a highlight of circlize 37 | } 38 | \description{ 39 | Group highlight 40 | } 41 | \examples{ 42 | highlightGroup(df,track.index = 1,palatte) 43 | } 44 | -------------------------------------------------------------------------------- /man/hyperBar.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_enrichBar.R 3 | \name{hyperBar} 4 | \alias{hyperBar} 5 | \title{hyper barplot} 6 | \usage{ 7 | hyperBar( 8 | res, 9 | top = 10, 10 | order_by = "pvalue", 11 | fill = "qvalue", 12 | x = "Count", 13 | wrap_limit = 25 14 | ) 15 | } 16 | \arguments{ 17 | \item{res}{a \code{\link[DOSE]{enrichResult}}} 18 | 19 | \item{top}{number of top categories to show, by pvalue} 20 | } 21 | \description{ 22 | hyper barplot 23 | } 24 | \examples{ 25 | hyperBar(res) 26 | } 27 | -------------------------------------------------------------------------------- /man/hyperMSigDB.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/msigdbResolve.R 3 | \name{hyperMSigDB} 4 | \alias{hyperMSigDB} 5 | \title{Hyper analysis of DEGContainer} 6 | \usage{ 7 | hyperMSigDB(object) 8 | } 9 | \arguments{ 10 | \item{object}{a DEGContainer} 11 | } 12 | \value{ 13 | a DEGContainer 14 | } 15 | \description{ 16 | Hyper analysis of DEGContainer 17 | } 18 | \examples{ 19 | hyperMSigDB(DEGContainer) 20 | } 21 | -------------------------------------------------------------------------------- /man/hyperMSigDB_Resolve.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/msigdbResolve.R 3 | \name{hyperMSigDB_Resolve} 4 | \alias{hyperMSigDB_Resolve} 5 | \title{Hyper analysis for MSigDB} 6 | \usage{ 7 | hyperMSigDB_Resolve(..., geneSet_list, msigdbHyperParam) 8 | } 9 | \arguments{ 10 | \item{...}{more parameters for \code{\link[clusterProfiler]{enricher}}} 11 | 12 | \item{geneSet_list}{a gene set list} 13 | 14 | \item{msigdbHyperParam}{parameters for hyper} 15 | } 16 | \value{ 17 | a list of ernrichResult 18 | } 19 | \description{ 20 | Hyper analysis for MSigDB 21 | } 22 | \examples{ 23 | hyperMSigDB_Resolve() 24 | } 25 | -------------------------------------------------------------------------------- /man/hyperResolve.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/hyperResolve.R 3 | \name{hyperResolve} 4 | \alias{hyperResolve} 5 | \title{Resolve Hyper} 6 | \usage{ 7 | hyperResolve(object, GO = FALSE, KEGG = TRUE) 8 | } 9 | \arguments{ 10 | \item{object}{DEGContainer} 11 | 12 | \item{GO}{run GO,TRUE or FALSE} 13 | 14 | \item{KEGG}{run KEGG,TRUE or FALSE} 15 | } 16 | \value{ 17 | DEGContainer 18 | } 19 | \description{ 20 | Resolve Hyper 21 | } 22 | \examples{ 23 | hyperResolve(object, GO = FALSE, KEGG = TRUE) 24 | } 25 | -------------------------------------------------------------------------------- /man/hyperSummary.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/hyperSummary.R 3 | \name{hyperSummary} 4 | \alias{hyperSummary} 5 | \title{Summary Hyper results} 6 | \usage{ 7 | hyperSummary(obj, dir = ".", prefix = "3-runHyper", top = 10) 8 | } 9 | \arguments{ 10 | \item{obj}{a DEGContainer} 11 | 12 | \item{dir}{a directory to store results} 13 | 14 | \item{prefix}{a prefix of file names in this step} 15 | 16 | \item{top}{top rows of up and down} 17 | } 18 | \value{ 19 | files 20 | } 21 | \description{ 22 | Summary Hyper results 23 | } 24 | \examples{ 25 | hyperSummary(DEGContainer) 26 | } 27 | -------------------------------------------------------------------------------- /man/hyper_GS.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{hyper_GS} 4 | \alias{hyper_GS} 5 | \title{Get a significant difference gene list} 6 | \usage{ 7 | hyper_GS(object, which, type, OrgDb = NULL, category = "H") 8 | } 9 | \arguments{ 10 | \item{object}{a DEGContainer} 11 | 12 | \item{which}{kinds of DEG; can be "limma", "edgeR", "DESeq2" or "MSigDB"} 13 | 14 | \item{type}{"ENTREZID" or "SYMBOL"} 15 | 16 | \item{OrgDb}{OrgDb} 17 | 18 | \item{category}{MSigDB collection abbreviation, such as H or C1.} 19 | } 20 | \description{ 21 | Get a significant difference gene list 22 | } 23 | \examples{ 24 | hyper_GS(object, which, type) 25 | } 26 | -------------------------------------------------------------------------------- /man/idLegend.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_enrichCirclize.R 3 | \name{idLegend} 4 | \alias{idLegend} 5 | \title{Legend for ID} 6 | \usage{ 7 | idLegend( 8 | df, 9 | palatte, 10 | type = "points", 11 | title = "Pathways", 12 | title_position = "topleft", 13 | ... 14 | ) 15 | } 16 | \arguments{ 17 | \item{df}{df} 18 | 19 | \item{palatte}{p} 20 | 21 | \item{type}{t} 22 | 23 | \item{title}{t} 24 | 25 | \item{title_position}{t} 26 | 27 | \item{text_width}{t} 28 | } 29 | \value{ 30 | a legend of circlize 31 | } 32 | \description{ 33 | Legend for ID 34 | } 35 | \examples{ 36 | idLegend(df, palatte) 37 | } 38 | -------------------------------------------------------------------------------- /man/limma_resolve.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/degResolve.R 3 | \name{limma_resolve} 4 | \alias{limma_resolve} 5 | \title{Basic produce of limma} 6 | \usage{ 7 | limma_resolve(counts_data, group_list, control_group, case_group) 8 | } 9 | \arguments{ 10 | \item{counts_data}{a counts data frame of rows in genes and columns in samples} 11 | 12 | \item{group_list}{a character vector ordered by samples in counts_data} 13 | 14 | \item{control_group}{the name of the denominator level for the fold change (Control group)} 15 | 16 | \item{case_group}{the name of the numerator level for the fold change (Test group)} 17 | } 18 | \value{ 19 | a DEG data frame 20 | } 21 | \description{ 22 | A basic function to get data and produce results of limma 23 | } 24 | \examples{ 25 | limma_resolve(counts_input, group_list, control_group= "C", case_group = "T") 26 | } 27 | -------------------------------------------------------------------------------- /man/limma_resolveArray.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/degResolveArray.R 3 | \name{limma_resolveArray} 4 | \alias{limma_resolveArray} 5 | \title{Basic produce of limma} 6 | \usage{ 7 | limma_resolveArray(expr_data, group_list, control_group, case_group) 8 | } 9 | \arguments{ 10 | \item{expr_data}{a counts data frame of rows in genes and columns in samples} 11 | 12 | \item{group_list}{a character vector ordered by samples in counts_data} 13 | 14 | \item{control_group}{the name of the denominator level for the fold change (Control group)} 15 | 16 | \item{case_group}{the name of the numerator level for the fold change (Test group)} 17 | } 18 | \value{ 19 | a DEG data frame 20 | } 21 | \description{ 22 | A basic function to get data and produce results of limma 23 | } 24 | \examples{ 25 | limma_resolve(counts_input, group_list, control_group= "C", case_group = "T") 26 | } 27 | -------------------------------------------------------------------------------- /man/linkCir.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_enrichCirclize.R 3 | \name{linkCir} 4 | \alias{linkCir} 5 | \title{Create matrix for circlize chordDiagram} 6 | \usage{ 7 | linkCir(df, group = "model") 8 | } 9 | \arguments{ 10 | \item{df}{a data frame contains multigroup results of enrich} 11 | 12 | \item{group}{which column is group data} 13 | } 14 | \value{ 15 | a matrix contains relations of IDs in group 16 | } 17 | \description{ 18 | Create matrix for circlize chordDiagram 19 | } 20 | \examples{ 21 | linkCir(df) 22 | } 23 | -------------------------------------------------------------------------------- /man/modelEnrich.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_enrichCirclize.R 3 | \name{modelEnrich} 4 | \alias{modelEnrich} 5 | \title{Get circlize data from obj after hyper analysis} 6 | \usage{ 7 | modelEnrich(obj, dataBase, orderBy = "pvalue", head = 3) 8 | } 9 | \arguments{ 10 | \item{obj}{obj} 11 | 12 | \item{dataBase}{KEGG or GO} 13 | 14 | \item{orderBy}{pvalue or other column} 15 | 16 | \item{head}{head after order} 17 | } 18 | \value{ 19 | a list 20 | } 21 | \description{ 22 | Get circlize data from obj after hyper analysis 23 | } 24 | \examples{ 25 | modelEnrich(obj) 26 | } 27 | -------------------------------------------------------------------------------- /man/msigdbGet.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/msigdbResolve.R 3 | \name{msigdbGet} 4 | \alias{msigdbGet} 5 | \title{Download MSigDB data for DEGContainer} 6 | \usage{ 7 | msigdbGet(object) 8 | } 9 | \arguments{ 10 | \item{object}{a DEGContainer} 11 | } 12 | \value{ 13 | a DEGContainer contains MSigDB data 14 | } 15 | \description{ 16 | Download MSigDB data for DEGContainer 17 | } 18 | \examples{ 19 | msigdbGet(degcontainer) 20 | } 21 | -------------------------------------------------------------------------------- /man/newDEGContainer.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/createOB.R 3 | \docType{methods} 4 | \name{newDEGContainer} 5 | \alias{newDEGContainer} 6 | \title{Initialize an object of class \code{DEGContainer}} 7 | \usage{ 8 | newDEGContainer( 9 | dataInfo = NULL, 10 | degResults = NULL, 11 | hyperResults = NULL, 12 | gseResults = NULL, 13 | MSigDB = NULL 14 | ) 15 | } 16 | \arguments{ 17 | \item{dataInfo}{a dataInfo object} 18 | 19 | \item{degResults}{a degResults object} 20 | 21 | \item{hyperResults}{a hyperResults object} 22 | 23 | \item{gseResults}{a gseResults object} 24 | 25 | \item{MSigDB}{a MSigDB object} 26 | } 27 | \value{ 28 | a DEGContainer 29 | } 30 | \description{ 31 | Constructs a \code{DEGContainer} object. Additional helper 32 | methods for manipulating \code{DEGContainer} objects are also 33 | described below. We now recommend using 34 | \code{Create_DEGContainer} to create objects, instead. 35 | } 36 | -------------------------------------------------------------------------------- /man/paletteCir.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_enrichCirclize.R 3 | \name{paletteCir} 4 | \alias{paletteCir} 5 | \title{Create a palette of ID across different group} 6 | \usage{ 7 | paletteCir( 8 | df, 9 | group = "model", 10 | palette = as.character(MetBrewer::met.brewer("Signac", length(unique(df$ID)))) 11 | ) 12 | } 13 | \arguments{ 14 | \item{df}{a data frame contains multigroup results of enrich} 15 | 16 | \item{group}{which column is group data} 17 | 18 | \item{palette}{a color vecter, should be length with unique ID} 19 | } 20 | \value{ 21 | a named palette 22 | } 23 | \description{ 24 | Create a palette of ID across different group 25 | } 26 | \examples{ 27 | paletteCir(df) 28 | } 29 | -------------------------------------------------------------------------------- /man/pca_check.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/runCheck.R 3 | \name{pca_check} 4 | \alias{pca_check} 5 | \title{PCA QC check} 6 | \usage{ 7 | pca_check( 8 | data, 9 | group, 10 | dir = ".", 11 | prefix = "1-run_check", 12 | palette = RColorBrewer::brewer.pal(3, "Set2")[1:2] 13 | ) 14 | } 15 | \arguments{ 16 | \item{data}{a cpm data frame of rows in genes and columns in samples} 17 | 18 | \item{group}{a list ordered by samples in data} 19 | 20 | \item{dir}{a directory to store results} 21 | 22 | \item{prefix}{a prefix of file names in this step} 23 | 24 | \item{palette}{a color palette for plots} 25 | } 26 | \value{ 27 | a figure of PCA 28 | } 29 | \description{ 30 | check data quality by PCA plot 31 | } 32 | \examples{ 33 | pca_check(data, group) 34 | } 35 | -------------------------------------------------------------------------------- /man/pipe.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils-pipe.R 3 | \name{\%>\%} 4 | \alias{\%>\%} 5 | \title{Pipe operator} 6 | \usage{ 7 | lhs \%>\% rhs 8 | } 9 | \arguments{ 10 | \item{lhs}{A value or the magrittr placeholder.} 11 | 12 | \item{rhs}{A function call using the magrittr semantics.} 13 | } 14 | \value{ 15 | The result of calling `rhs(lhs)`. 16 | } 17 | \description{ 18 | See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details. 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/pvalue_Identify.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{pvalue_Identify} 4 | \alias{pvalue_Identify} 5 | \title{Identify the column where the pvalue is located} 6 | \usage{ 7 | pvalue_Identify(res) 8 | } 9 | \arguments{ 10 | \item{res}{one of result from limma or DESeq2 or edgeR} 11 | } 12 | \value{ 13 | a column name 14 | } 15 | \description{ 16 | Identify the column where the pvalue is located 17 | } 18 | \examples{ 19 | pvalue_Identify(deg_data) 20 | } 21 | -------------------------------------------------------------------------------- /man/rectCir.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_enrichCirclize.R 3 | \name{rectCir} 4 | \alias{rectCir} 5 | \title{Plot rect in continuous value} 6 | \usage{ 7 | rectCir( 8 | preData, 9 | annoData, 10 | palatte, 11 | track.index = 1, 12 | ylim = c(0, 1), 13 | y1Scale = 0, 14 | y2Scale = 0.5 15 | ) 16 | } 17 | \arguments{ 18 | \item{preData}{data after pre plot} 19 | 20 | \item{annoData}{annotation data} 21 | 22 | \item{palatte}{palatte} 23 | 24 | \item{track.index}{index number} 25 | 26 | \item{ylim}{y range} 27 | 28 | \item{y1Scale}{adjust y start} 29 | 30 | \item{y2Scale}{adjust y end} 31 | } 32 | \value{ 33 | a rect plot of circlize 34 | } 35 | \description{ 36 | Plot rect in continuous value 37 | } 38 | \examples{ 39 | rectCir(preData, annoData, palatte) 40 | } 41 | -------------------------------------------------------------------------------- /man/rectCirDiscrete.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_enrichCirclize.R 3 | \name{rectCirDiscrete} 4 | \alias{rectCirDiscrete} 5 | \title{plot rect in discrete value} 6 | \usage{ 7 | rectCirDiscrete( 8 | preData, 9 | annoData, 10 | palatte, 11 | track.index = 1, 12 | ylim = c(0, 1), 13 | y1Scale = 0, 14 | y2Scale = 0.5 15 | ) 16 | } 17 | \arguments{ 18 | \item{preData}{preData} 19 | 20 | \item{annoData}{annoData} 21 | 22 | \item{palatte}{palatte} 23 | 24 | \item{track.index}{track.index} 25 | 26 | \item{ylim}{ylim} 27 | 28 | \item{y1Scale}{y1Scale} 29 | 30 | \item{y2Scale}{y2Scale} 31 | } 32 | \value{ 33 | a rect plot of circlize 34 | } 35 | \description{ 36 | plot rect in discrete value 37 | } 38 | \examples{ 39 | rectCirDiscrete(preData, annoData, palatte) 40 | } 41 | -------------------------------------------------------------------------------- /man/runALL.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/runALL.R 3 | \name{runALL} 4 | \alias{runALL} 5 | \title{run all workflow} 6 | \usage{ 7 | runALL(object, dir = "output", top = 10, parallel = T, GO = FALSE, KEGG = TRUE) 8 | } 9 | \arguments{ 10 | \item{object}{a DEGContainer} 11 | 12 | \item{dir}{a directory to store results} 13 | 14 | \item{top}{top for enrich result filter} 15 | 16 | \item{parallel}{use parallel in DESeq2} 17 | 18 | \item{GO}{logic, run GO in enrich step} 19 | 20 | \item{KEGG}{logic, run KEGG in enrich step} 21 | } 22 | \value{ 23 | a DEGContainer 24 | } 25 | \description{ 26 | runALL include runCheck runDEG runHyper runGSEA runMSigDB 27 | } 28 | -------------------------------------------------------------------------------- /man/runCheck.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/runCheck.R 3 | \name{runCheck} 4 | \alias{runCheck} 5 | \title{Check you data by PCA and Heatmaps} 6 | \usage{ 7 | runCheck( 8 | object, 9 | dir = ".", 10 | prefix = "1-run_check", 11 | palette = RColorBrewer::brewer.pal(3, "Set2")[1:2] 12 | ) 13 | } 14 | \arguments{ 15 | \item{object}{a DEGContainer contains at least dataInfo} 16 | 17 | \item{dir}{a directory to store results} 18 | 19 | \item{prefix}{a prefix of file names in this step} 20 | 21 | \item{palette}{a color palette for plots} 22 | } 23 | \description{ 24 | A previous check function for overview the data sets. 25 | } 26 | \examples{ 27 | runCheck(object, tempdir()) 28 | } 29 | -------------------------------------------------------------------------------- /man/runDEG.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/runDEG.R 3 | \name{runDEG} 4 | \alias{runDEG} 5 | \title{run DEG analysis} 6 | \usage{ 7 | runDEG( 8 | obj, 9 | dir = ".", 10 | prefix = "2-runDEG", 11 | parallel = TRUE, 12 | qc = TRUE, 13 | PointVolcanoParam = list(gene = 10, light = NULL, light_color = "#24ac56", 14 | light_label_color = "#24ac56", expend = c(0.12, 0.12)) 15 | ) 16 | } 17 | \arguments{ 18 | \item{obj}{a DEGContainer} 19 | 20 | \item{dir}{a directory to store results} 21 | 22 | \item{prefix}{a prefix of file names in this step} 23 | 24 | \item{parallel}{use parallel in DESeq2} 25 | 26 | \item{qc}{qc in DESeq2} 27 | 28 | \item{PointVolcanoParam}{for volcano plot} 29 | } 30 | \description{ 31 | run DEG analysis and summary results 32 | } 33 | \examples{ 34 | runDEG(DEGContainer) 35 | } 36 | -------------------------------------------------------------------------------- /man/runGSEA.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/runGSEA.R 3 | \name{runGSEA} 4 | \alias{runGSEA} 5 | \title{runGSEA Module} 6 | \usage{ 7 | runGSEA( 8 | obj, 9 | dir = ".", 10 | prefix = "4-runGSEA", 11 | top = 10, 12 | GO = FALSE, 13 | KEGG = TRUE 14 | ) 15 | } 16 | \arguments{ 17 | \item{obj}{a DEGContainer} 18 | 19 | \item{dir}{a directory to store results} 20 | 21 | \item{prefix}{a prefix of file names in this step} 22 | 23 | \item{top}{top rows of up and down} 24 | 25 | \item{GO}{run GO} 26 | 27 | \item{KEGG}{run KEGG} 28 | } 29 | \description{ 30 | runGSEA Module control GO and KEGG 31 | } 32 | \examples{ 33 | runGSEA(DEGContainer) 34 | } 35 | -------------------------------------------------------------------------------- /man/runHyper.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/runHyper.R 3 | \name{runHyper} 4 | \alias{runHyper} 5 | \title{runHyper} 6 | \usage{ 7 | runHyper( 8 | obj, 9 | dir = ".", 10 | prefix = "3-runHyper", 11 | top = 10, 12 | GO = FALSE, 13 | KEGG = TRUE 14 | ) 15 | } 16 | \arguments{ 17 | \item{obj}{a DEGContainer} 18 | 19 | \item{dir}{a directory to store results} 20 | 21 | \item{prefix}{a prefix of file names in this step} 22 | 23 | \item{top}{top for enrich result filter} 24 | 25 | \item{GO}{logic, run GO in enrich step} 26 | 27 | \item{KEGG}{logic, run KEGG in enrich step} 28 | } 29 | \value{ 30 | a DEGContainer 31 | } 32 | \description{ 33 | runHyper 34 | } 35 | \examples{ 36 | runHyper(DEGContainer) 37 | } 38 | -------------------------------------------------------------------------------- /man/runMSigDB.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/runMSigDB.R 3 | \name{runMSigDB} 4 | \alias{runMSigDB} 5 | \title{run MSigDB module} 6 | \usage{ 7 | runMSigDB(obj, dir = ".", prefix = "5-runMSigDB", top = 10) 8 | } 9 | \arguments{ 10 | \item{obj}{a DEGContainer after MSigDB analysis} 11 | 12 | \item{dir}{a directory to store results} 13 | 14 | \item{prefix}{a prefix of file names in this step} 15 | 16 | \item{top}{top} 17 | } 18 | \description{ 19 | run MSigDB module 20 | } 21 | \examples{ 22 | runMSigDB(data_gse) 23 | } 24 | -------------------------------------------------------------------------------- /man/textBarData.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_enrichBar.R 3 | \name{textBarData} 4 | \alias{textBarData} 5 | \title{shape data of enrichResult} 6 | \usage{ 7 | textBarData( 8 | enrichResult, 9 | richFactor = FALSE, 10 | top = 10, 11 | group = "ONTOLOGY", 12 | order_by = "pvalue" 13 | ) 14 | } 15 | \arguments{ 16 | \item{enrichResult}{a \code{\link[DOSE]{enrichResult}}} 17 | 18 | \item{richFactor}{need to add richFactor?} 19 | 20 | \item{top}{number of top categories to show, by order_by} 21 | 22 | \item{group}{group data in which column} 23 | 24 | \item{order_by}{order data by which column} 25 | } 26 | \description{ 27 | shape data of enrichResult 28 | } 29 | \examples{ 30 | textBarData(enrichResult) 31 | } 32 | -------------------------------------------------------------------------------- /man/theme_volcano.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_DEGvolcano.R 3 | \name{theme_volcano} 4 | \alias{theme_volcano} 5 | \title{theme_volcano} 6 | \usage{ 7 | theme_volcano(...) 8 | } 9 | \arguments{ 10 | \item{...}{param passed from theme} 11 | } 12 | \value{ 13 | a ggplot theme 14 | } 15 | \description{ 16 | a nice theme for DEG volcano 17 | } 18 | -------------------------------------------------------------------------------- /man/toSYMBOL.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{toSYMBOL} 4 | \alias{toSYMBOL} 5 | \title{Convert a ENSEMBL named data to SYMBOL named} 6 | \usage{ 7 | toSYMBOL(row_counts, species) 8 | } 9 | \arguments{ 10 | \item{row_counts}{count data frame} 11 | 12 | \item{species}{support Human Mouse Rat} 13 | } 14 | \value{ 15 | a renamed dataframe 16 | } 17 | \description{ 18 | larger median will be retain for duplicated 19 | } 20 | \examples{ 21 | toSYMBOL(count,b2g) 22 | } 23 | -------------------------------------------------------------------------------- /man/top1000_check.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/runCheck.R 3 | \name{top1000_check} 4 | \alias{top1000_check} 5 | \title{Heatmap of all samples and Top1000 genes} 6 | \usage{ 7 | top1000_check( 8 | data, 9 | group, 10 | dir = ".", 11 | prefix = "1-run_check", 12 | palette = RColorBrewer::brewer.pal(3, "Set2")[1:2] 13 | ) 14 | } 15 | \arguments{ 16 | \item{data}{a cpm data frame of rows in genes and columns in samples} 17 | 18 | \item{group}{a list ordered by samples in data} 19 | 20 | \item{dir}{a directory to store results} 21 | 22 | \item{prefix}{a prefix of file names in this step} 23 | 24 | \item{palette}{a color palette for plots} 25 | } 26 | \value{ 27 | a Heatmap shows top100 genes of all samples 28 | } 29 | \description{ 30 | Check data quality by plotting heatmap of top 1000 genes 31 | } 32 | \examples{ 33 | top1000_check(data, group) 34 | } 35 | -------------------------------------------------------------------------------- /man/topGene.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{topGene} 4 | \alias{topGene} 5 | \title{Choose top genes from DEG data frame of limma DESeq2 edgeR} 6 | \usage{ 7 | topGene(object, topSig = 50, which, category = "H") 8 | } 9 | \arguments{ 10 | \item{object}{a DEG data frame contains logFC and p value} 11 | 12 | \item{topSig}{a single number or a length of 2 numeric vector, if 2 numeric vector, first one is top max logFC.} 13 | 14 | \item{which}{a single number for threshold value of P value} 15 | } 16 | \value{ 17 | a character vector of top genes 18 | } 19 | \description{ 20 | For example, if topSig = 50, head 50 and tail 50 will return from a 21 | ordered DEG data frame after filtering by threshold value of P value 22 | } 23 | \examples{ 24 | topGene(object, topSig = 50, which = "limma") 25 | } 26 | -------------------------------------------------------------------------------- /man/volcano_nudge_x_down.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_DEGvolcano.R 3 | \name{volcano_nudge_x_down} 4 | \alias{volcano_nudge_x_down} 5 | \title{nudge gene labels in x direction in down side} 6 | \usage{ 7 | volcano_nudge_x_down(object, label_data, which, just = 0, category = "H") 8 | } 9 | \arguments{ 10 | \item{object}{a grouped DEGContainer} 11 | 12 | \item{label_data}{genePoint} 13 | 14 | \item{which}{kinds of DEG; can be "limma", "edgeR", "DESeq2" or "MSigDB"} 15 | 16 | \item{just}{just position} 17 | 18 | \item{category}{for \code{which} is "MSigDB"} 19 | } 20 | \description{ 21 | values for \code{nudge_x} in \code{\link{geom_volcano_text}} 22 | } 23 | -------------------------------------------------------------------------------- /man/volcano_nudge_x_up.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Visualization_DEGvolcano.R 3 | \name{volcano_nudge_x_up} 4 | \alias{volcano_nudge_x_up} 5 | \title{nudge gene labels in x direction in up side} 6 | \usage{ 7 | volcano_nudge_x_up(object, label_data, which, just = 0, category = "H") 8 | } 9 | \arguments{ 10 | \item{object}{a grouped DEGContainer} 11 | 12 | \item{label_data}{genePoint} 13 | 14 | \item{which}{kinds of DEG; can be "limma", "edgeR", "DESeq2" or "MSigDB"} 15 | 16 | \item{just}{just position} 17 | 18 | \item{category}{for \code{which} is "MSigDB"} 19 | } 20 | \description{ 21 | values for \code{nudge_x} in \code{\link{geom_volcano_text}} 22 | } 23 | --------------------------------------------------------------------------------