├── .gitignore ├── DESCRIPTION ├── LICENSE ├── NAMESPACE ├── R ├── VCFserver.R ├── VCFui.R └── runApp.R ├── README.md ├── VCFshiny.Rproj ├── inst ├── .DS_Store ├── Annovar │ ├── Annovar_Datebase_Table.CSV │ ├── annotate_variation.pl │ ├── coding_change.pl │ ├── convert2annovar.pl │ ├── retrieve_seq_from_fasta.pl │ ├── table_annovar.pl │ └── variants_reduction.pl ├── extdata │ ├── IntOGen_cancer_driver_gene.rds │ ├── VCFshiny_Circos_Chrom_hg38.txt │ └── example_data.rds ├── markdown │ ├── images │ │ ├── Fold_Format.png │ │ ├── Input File Format.png │ │ └── workflow.jpg │ ├── installation.html │ └── installation.md └── shiny │ ├── modules │ ├── 0.Introduction.R │ ├── 1.Upload_server.R │ ├── 1.Upload_ui.R │ ├── 10.mutational_signature_server.R │ ├── 10.mutational_signature_ui.R │ ├── 11.Annotation_server.R │ ├── 11.Annotation_ui.R │ ├── 2.Venn_server.R │ ├── 2.Venn_ui.R │ ├── 3.summarise_barplot_server.R │ ├── 3.summarise_barplot_ui.R │ ├── 4.SNP_Analysis_server.R │ ├── 4.SNP_Analysis_ui.R │ ├── 5.Indel_Analysis_server.R │ ├── 5.Indel_Analysis_ui.R │ ├── 6.circle_server.R │ ├── 6.circle_ui.R │ ├── 7.Distribution_server.R │ ├── 7.Distribution_ui.R │ ├── 8.VariantsGene_Summarise_server.R │ ├── 8.VariantsGene_Summarise_ui.R │ ├── 9.VariantsGene_Heatmap_server.R │ └── 9.VariantsGene_Heatmap_ui.R │ └── www │ ├── custom.css │ └── radar_style.css └── man ├── VCFserver.Rd ├── VCFui.Rd ├── hello.Rd └── startVCFshiny.Rd /.gitignore: -------------------------------------------------------------------------------- 1 | # History files 2 | .Rhistory 3 | .Rapp.history 4 | 5 | # Session Data files 6 | .RData 7 | 8 | # User-specific files 9 | .Ruserdata 10 | 11 | # Example code in package build process 12 | *-Ex.R 13 | 14 | # Output files from R CMD build 15 | /*.tar.gz 16 | 17 | # Output files from R CMD check 18 | /*.Rcheck/ 19 | 20 | # RStudio files 21 | .Rproj.user/ 22 | 23 | # produced vignettes 24 | vignettes/*.html 25 | vignettes/*.pdf 26 | 27 | # OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 28 | .httr-oauth 29 | 30 | # knitr and R markdown default cache directories 31 | *_cache/ 32 | /cache/ 33 | 34 | # Temporary files created by R markdown 35 | *.utf8.md 36 | *.knit.md 37 | 38 | # R Environment Variables 39 | .Renviron 40 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: VCFshiny 2 | Type: Package 3 | Title: What the Package Does (Title Case) 4 | Version: 0.1.0 5 | Author: Who wrote it 6 | Maintainer: The package maintainer 7 | Description: More about what it does (maybe more than one line) 8 | Use four spaces when indenting paragraphs within the Description. 9 | License: What license is it under? 10 | Encoding: UTF-8 11 | LazyData: true 12 | RoxygenNote: 7.2.2 13 | Imports: 14 | circlize, 15 | dplyr, 16 | DT, 17 | ggplot2, 18 | ggpubr, 19 | grDevices, 20 | pheatmap, 21 | shiny, 22 | shinyBS, 23 | shinydashboard, 24 | shinyWidgets, 25 | tibble, 26 | vcfR 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Xiao-Chen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(VCFserver) 4 | export(VCFui) 5 | export(startVCFshiny) 6 | importFrom(dplyr,"%>%") 7 | importFrom(shiny,addResourcePath) 8 | importFrom(shiny,br) 9 | importFrom(shiny,fluidPage) 10 | importFrom(shiny,fluidRow) 11 | importFrom(shiny,hr) 12 | importFrom(shiny,icon) 13 | importFrom(shiny,includeHTML) 14 | importFrom(shiny,navbarMenu) 15 | importFrom(shiny,navbarPage) 16 | importFrom(shiny,p) 17 | importFrom(shiny,runApp) 18 | importFrom(shiny,shinyApp) 19 | importFrom(shiny,shinyUI) 20 | importFrom(shiny,strong) 21 | importFrom(shiny,tabPanel) 22 | importFrom(shiny,tags) 23 | importFrom(shinyBS,bsModal) 24 | importFrom(shinyWidgets,useShinydashboard) 25 | importFrom(shinydashboard,box) 26 | importFrom(shinyjs,useShinyjs) 27 | -------------------------------------------------------------------------------- /R/VCFserver.R: -------------------------------------------------------------------------------- 1 | #' create the server functions 2 | #' 3 | #' @param input shiny input 4 | #' @param output shiny output 5 | #' @param session shiny session 6 | #' 7 | #' @export 8 | 9 | VCFserver <- function(input, output, session) { 10 | require(ggplot2) 11 | require(ggpubr) 12 | require(dplyr) 13 | require(circlize) 14 | require(tibble) 15 | require(pheatmap) 16 | 17 | require(GenomicRanges) 18 | require(IRanges) 19 | require(TxDb.Hsapiens.UCSC.hg38.knownGene) 20 | require(TxDb.Hsapiens.UCSC.hg19.knownGene) 21 | require(org.Hs.eg.db) 22 | require(musicatk) 23 | 24 | source(system.file("shiny", "modules/1.Upload_server.R", package = "VCFshiny"), local = T) 25 | source(system.file("shiny", "modules/2.Venn_server.R", package = "VCFshiny"), local = T) 26 | source(system.file("shiny", "modules/3.summarise_barplot_server.R", package = "VCFshiny"), local = T) 27 | source(system.file("shiny", "modules/4.SNP_Analysis_server.R", package = "VCFshiny"), local = T) 28 | source(system.file("shiny", "modules/5.Indel_Analysis_server.R", package = "VCFshiny"), local = T) 29 | source(system.file("shiny", "modules/6.circle_server.R", package = "VCFshiny"), local = T) 30 | source(system.file("shiny", "modules/7.Distribution_server.R", package = "VCFshiny"), local = T) 31 | source(system.file("shiny", "modules/8.VariantsGene_Summarise_server.R", package = "VCFshiny"), local = T) 32 | source(system.file("shiny", "modules/9.VariantsGene_Heatmap_server.R", package = "VCFshiny"), local = T) 33 | source(system.file("shiny", "modules/10.mutational_signature_server.R", package = "VCFshiny"), local = T) 34 | source(system.file("shiny", "modules/11.Annotation_server.R", package = "VCFshiny"), local = T) 35 | } 36 | -------------------------------------------------------------------------------- /R/VCFui.R: -------------------------------------------------------------------------------- 1 | #' Build shiny UI page 2 | #' 3 | #' @importFrom shinyjs useShinyjs 4 | #' @importFrom shinyWidgets useShinydashboard 5 | #' @importFrom shiny shinyUI fluidPage navbarPage tabPanel icon includeHTML br hr navbarMenu fluidRow strong p tags 6 | #' @importFrom shinydashboard box 7 | #' @importFrom shinyBS bsModal 8 | #' 9 | #' @export 10 | #' 11 | VCFui <- function() { 12 | require(DT) 13 | require(shiny) 14 | require(shinyBS) 15 | require(shinyWidgets) 16 | require(shinydashboard) 17 | 18 | 19 | 20 | dashboardPage( 21 | # skin = "black", 22 | #Header ------------------------------------------------------------------------------------------------------------------------------- 23 | dashboardHeader(title ="VCF Analyse" , titleWidth = 250), 24 | #Sider--------------------------------------------------------------------------------------------------------------------------------- 25 | dashboardSidebar( 26 | width = 250, 27 | sidebarMenu( 28 | menuItem("Introduction",tabName = "introduction",icon = icon("home")), 29 | menuItem("Data Input", icon = icon("upload"), tabName = "datainput"), 30 | menuItem("Venn Diagram", icon = icon("chart-bar"), tabName = "venn_analyse"), 31 | menuItem("Variants Number", icon = icon("chart-bar"), tabName = "ALL_variants"), 32 | menuItem("SNVs Exploration", icon = icon("chart-bar"), tabName = "snp_analysis"), 33 | menuItem("Indels Exploration", icon = icon("chart-bar"), tabName = "Indel_analysis"), 34 | menuItem("Genome Circos Plot", icon = icon("chart-bar"), tabName = "circle"), 35 | menuItem("Genomic Features",icon = icon("chart-bar"), tabName = "distribution"), 36 | menuItem("Variants Relevant Genes", icon = icon("chart-bar"), tabName = "Variants_summarise"), 37 | menuItem("Cancer Driver Genes", icon = icon("chart-bar"), tabName = "Variants_heatmap"), 38 | menuItem("Cancer Mutational Signature", icon = icon("chart-bar"), tabName = "cancer_signature"), 39 | menuItem("Data Annotation", icon = icon("book"), tabName = "dataAnno") 40 | ) 41 | ), 42 | 43 | #BODY -------------------------------------------------------------------------------------------------------------------------------------------------- 44 | dashboardBody( 45 | includeCSS(path = system.file("shiny", "www/custom.css", package = "VCFshiny")), 46 | tags$head(tags$style(HTML(' 47 | .main-header .logo { 48 | font-family: "Georgia", Times, "Times New Roman", serif; 49 | font-weight: bold; 50 | font-size: 24px; 51 | } 52 | '))), 53 | ### 读入数据 --------------------------------------------------------------------------------------------------------- 54 | tabItems( 55 | source(system.file("shiny", "modules/0.Introduction.R", package = "VCFshiny"), local = T)$value, 56 | source(system.file("shiny", "modules/1.Upload_ui.R", package = "VCFshiny"), local = T)$value, 57 | ### 第一部分 --------------------------------------------------------------------------------------------------------------------------------------------- 58 | source(system.file("shiny", "modules/2.Venn_ui.R", package = "VCFshiny"), local = T)$value, 59 | source(system.file("shiny", "modules/3.summarise_barplot_ui.R", package = "VCFshiny"), local = T)$value, 60 | source(system.file("shiny", "modules/4.SNP_Analysis_ui.R", package = "VCFshiny"), local = T)$value, 61 | source(system.file("shiny", "modules/5.Indel_Analysis_ui.R", package = "VCFshiny"), local = T)$value, 62 | source(system.file("shiny", "modules/6.circle_ui.R", package = "VCFshiny"), local = T)$value, 63 | ### 第二部分 -------------------------------------------------------------------------------------------------------------------------------- 64 | source(system.file("shiny", "modules/7.Distribution_ui.R", package = "VCFshiny"), local = T)$value, 65 | source(system.file("shiny", "modules/8.VariantsGene_Summarise_ui.R", package = "VCFshiny"), local = T)$value, 66 | source(system.file("shiny", "modules/9.VariantsGene_Heatmap_ui.R", package = "VCFshiny"), local = T)$value, 67 | source(system.file("shiny", "modules/10.mutational_signature_ui.R", package = "VCFshiny"), local = T)$value, 68 | source(system.file("shiny", "modules/11.Annotation_ui.R", package = "VCFshiny"), local = T)$value 69 | ) 70 | ) 71 | ) 72 | } 73 | -------------------------------------------------------------------------------- /R/runApp.R: -------------------------------------------------------------------------------- 1 | #' Start the VCF shiny App 2 | #' 3 | #' @importFrom dplyr %>% 4 | #' @importFrom shiny shinyApp runApp addResourcePath 5 | #' @export 6 | #' 7 | 8 | startVCFshiny <- function(launch.browser = TRUE, port = getOption("shiny.port"), host = getOption("shiny.host", "127.0.0.1")) { 9 | 10 | # set upload file size limit as 100MB 11 | options(shiny.maxRequestSize = 1000 * 1024^2, warn = -1, shiny.sanitize.errors = TRUE) 12 | 13 | # addResourcePath(prefix = "Annovar", directoryPath = system.file("Annovar", ".", package = "VCFshiny")) 14 | 15 | shinyApp(ui = VCFui, server = VCFserver) %>% runApp(launch.browser = launch.browser, host = host, port = port) 16 | } 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Abstract

2 | 3 |

Variants produced by next-generation sequencing are often recoded in variant call format (VCF) files. The VCF file stores the details of variations, including chromosome location, base sequence, base quality, read depth, genotype, etc. However, deciphering relevant biological insights from the VCF file can be a challenging task for studies without bioinformatics and programming backgrounds. Here, we described an R/Shiny application package named VCFshiny for interpreting and visualizing the variants stored in VCF files in an interactive and user-friendly way. VCFshiny enables the summary of variant information, including total variant numbers, variant overlap across samples, base alteration of single-nucleotide variants, length distribution of insertion and deletion, variant-related genes, variant distribution in the genome, and local variants in cancer driver genes. In each analysis session, we provided multiple visualization methods to help obtain an intuitive graph for publishing and sharing.

4 | 5 | 6 | 7 |

Getting Start

8 | 9 |

Requirements

10 | (1). R (>= 4.2.0).
11 | (2). Shiny (>= 1.6.0) 12 | 13 |

How to install shiny package:

14 | 15 | ``` 16 | ## Open R ## you may need open R first: 17 | install.package("shiny") 18 | ``` 19 | 20 |

How to install VCFshiny package:

21 | 22 | ``` 23 | ## install.packages("devtools") ## you may need install devtools first 24 | devtools::install_github("123xiaochen/VCFshiny") 25 | ``` 26 |

Getting Start

27 | 28 | ``` 29 | ## Loading and run the package. 30 | library(VCFshiny) 31 | VCFshiny::startVCFshiny() 32 | ``` 33 |

Prepare Data

34 |

In this section, we will introduce how to prepare two different input data sets:

35 | 36 |

Source of VCF input data

37 |

The Variant Call Format (VCF) is used to record gene sequence variations. It is also the first file format to be understood for genome population correlation analysis. First, the whole genome sequencing file is mapping to the reference, and then the resulting bam file is comprehensively analyzed using variant calling software such as GATK and the reference genome data to produce the VCF result.

38 | 39 |

Source of TXT input data

40 |

TXT files are one of several output formats annotated by Annovar (Wang K, Li M, Hakonarson H. 2010), which is able to analyze genetic variations in various genomes using the latest data. Since the input data VCF file of Annovar software only contains the starting position of the mutation, it is necessary to adjust the input data before using, and add the end position of the mutation after the actual position of the mutation. Gene-based annotations reveal variant's direct relationship with known genes and its functional impact, while region-based annotations reveal Variant's relationship with specific segments of different genomes.

41 | 42 |

Input data requirements

43 | 44 |

The input file requires all data to be stored in a compressed folder in the format of the file name.

45 | 46 |

Input compress files requirements

47 | 48 | 49 | 50 | (1). The compressed file name must be the same as the name of the compressed folder.
51 | (2). The compressed file can be in *.tar. gz or *.zip format. 52 | 53 |

Input File Name Requirements

54 | 55 | 56 | 57 | (1). The first box represents the sample name, which can be the group of experiments and the number of repetitions, connected by the character "-" or "_".
58 | (2). The second box represents the data type, which can be snp or indel data. When snp and indel are not classified in the data, this box can be absent **(I)**.
59 | (3). The third box represents the data format, which can be vcf files, vcf. gz compressed files, and Annovar annotated TXT files.
60 | (4). The contents of the three boxes are connected by ".". 61 | 62 |

Documentation

63 | 64 | The documentation is available at here , the doc include a tutorial and example gallery. 65 | 66 |

Development

67 | 68 | VCFshiny development takes place on Github: https://github.com/123xiaochen/VCFshiny 69 | 70 | Please submit any reproducible bugs you encounter to the issue tracker 71 | 72 | We will also put most commonly encountered issues in the ***FAQ*** page. 73 | 74 | -------------------------------------------------------------------------------- /VCFshiny.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 | -------------------------------------------------------------------------------- /inst/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/123xiaochen/VCFshiny/f0f451c2ea4f2733ca89eebac98e360997c60298/inst/.DS_Store -------------------------------------------------------------------------------- /inst/Annovar/Annovar_Datebase_Table.CSV: -------------------------------------------------------------------------------- 1 | Version,Name,Database_Type,Explanation,Date,Webfrom 2 | hg18,cytoBand,region-based,A cytoband file is a five-column tab-delimited text file. Each row of the file describes the position of a cytogenetic band.?,,UCSC 3 | hg19,cytoBand,region-based,same as above,,UCSC 4 | hg38,cytoBand,region-based,same as above,,UCSC 5 | hg19,refGene,gene-based,FASTA sequences for all annotated transcripts in RefSeq Gene,20211019,Annovar 6 | hg38,refGene,gene-based,FASTA sequences for all annotated transcripts in RefSeq Gene,20211019,Annovar 7 | hg18,refGeneWithVer,gene-based,FASTA sequences for all annotated transcripts in RefSeq Gene with version number?,20211019,Annovar 8 | hg19,refGeneWithVer,gene-based,FASTA sequences for all annotated transcripts in RefSeq Gene with version number?,20211019,Annovar 9 | hg38,refGeneWithVer,gene-based,FASTA sequences for all annotated transcripts in RefSeq Gene with version number?,20211019,Annovar 10 | hg18,knownGene,gene-based,FASTA sequences for all annotated transcripts in UCSC Known Gene,20211019,Annovar 11 | hg19,knownGene,gene-based,FASTA sequences for all annotated transcripts in UCSC Known Gene,20211019,Annovar 12 | hg38,knownGene,gene-based,FASTA sequences for all annotated transcripts in UCSC Known Gene,20211019,Annovar 13 | hg18,ensGene,gene-based,FASTA sequences for all annotated transcripts in wgEncodeGencodeManualV3 collection,20211019,Annovar 14 | hg19,ensGene,gene-based,FASTA sequences for all annotated transcripts in Gencode v43 Basic collection lifted up to hg19,20230315,Annovar 15 | hg38,ensGene,gene-based,FASTA sequences for all annotated transcripts in Gencode v43 Basic collection,20230315,Annovar 16 | hg19,ensGene40,gene-based,FASTA sequences for all annotated transcripts in Gencode v40 Basic collection lifted up to hg19,20220802,Annovar 17 | hg38,ensGene40,gene-based,FASTA sequences for all annotated transcripts in Gencode v40 Basic collection,20220802,Annovar 18 | hg19,ensGene41,gene-based,FASTA sequences for all annotated transcripts in Gencode v41 Basic collection lifted up to hg19,20221005,Annovar 19 | hg38,ensGene41,gene-based,FASTA sequences for all annotated transcripts in Gencode v41 Basic collection,20221005,Annovar 20 | hg18,ljb26_all,filter-based,"whole-exome SIFT, PolyPhen2 HDIV, PolyPhen2 HVAR, LRT, MutationTaster, MutationAssessor, FATHMM, MetaSVM, MetaLR, VEST, CADD, GERP++, PhyloP and SiPhy scores from dbNSFP version 2.6",20140925,Annovar 21 | hg19,ljb26_all,filter-based,same as above,20140925,Annovar 22 | hg38,ljb26_all,filter-based,same as above,20150520,Annovar 23 | hg18,dbnsfp30a,filter-based,"whole-exome SIFT, PolyPhen2 HDIV, PolyPhen2 HVAR, LRT, MutationTaster, MutationAssessor, FATHMM, MetaSVM, MetaLR, VEST, CADD, GERP++, DANN, fitCons, PhyloP and SiPhy scores from dbNSFP version 3.0a",20151015,Annovar 24 | hg19,dbnsfp30a,filter-based,same as above,20151015,Annovar 25 | hg38,dbnsfp30a,filter-based,same as above,20151015,Annovar 26 | hg19,dbnsfp31a_interpro,filter-based,protein domain for variants,20151219,Annovar 27 | hg38,dbnsfp31a_interpro,filter-based,same as above,20151219,Annovar 28 | hg18,dbnsfp33a,filter-based,"whole-exome SIFT, PolyPhen2 HDIV, PolyPhen2 HVAR, LRT, MutationTaster, MutationAssessor, FATHMM, PROVEAN, MetaSVM, MetaLR, VEST, M-CAP, CADD, GERP++, DANN, fathmm-MKL, Eigen, GenoCanyon, fitCons, PhyloP and SiPhy scores from dbNSFP version 3.3a",20170221,Annovar 29 | hg19,dbnsfp33a,filter-based,same as above,20170221,Annovar 30 | hg38,dbnsfp33a,filter-based,same as above,20170221,Annovar 31 | hg18,dbnsfp35a,filter-based,same as above,20180921,Annovar 32 | hg19,dbnsfp35a,filter-based,same as above,20180921,Annovar 33 | hg38,dbnsfp35a,filter-based,same as above,20180921,Annovar 34 | hg18,dbnsfp35c,filter-based,"same as above, suitable for commercial use",20181023,Annovar 35 | hg19,dbnsfp35c,filter-based,same as above,20181023,Annovar 36 | hg38,dbnsfp35c,filter-based,same as above,20181023,Annovar 37 | hg19,dbnsfp41a,filter-based,same as above,20201007,Annovar 38 | hg38,dbnsfp41a,filter-based,same as above,20201007,Annovar 39 | hg19,dbnsfp41c,filter-based,"same as above, suitable for commerical use",20201007,Annovar 40 | hg38,dbnsfp41c,filter-based,same as above,20201007,Annovar 41 | hg18,dbnsfp42a,filter-based,reformatted to include more columns than dbnsfp41a,20210710,Annovar 42 | hg19,dbnsfp42a,filter-based,same as above,20210710,Annovar 43 | hg38,dbnsfp42a,filter-based,same as above,20210710,Annovar 44 | hg18,dbnsfp42c,filter-based,"reformatted to include more columns than dbnsfp41a, commerical use",20210710,Annovar 45 | hg19,dbnsfp42c,filter-based,same as above,20210710,Annovar 46 | hg38,dbnsfp42c,filter-based,same as above,20210710,Annovar 47 | hg19,dbscsnv11,filter-based,dbscSNV version 1.1 for splice site prediction by AdaBoost and Random Forest,20151218,Annovar 48 | hg38,dbscsnv11,filter-based,same as above,20151218,Annovar 49 | hg19,intervar_20170202,filter-based,InterVar: clinical interpretation of missense variants (indels not supported),20170202,Annovar 50 | hg19,intervar_20180118,filter-based,InterVar: clinical interpretation of missense variants (indels not supported),20180325,Annovar 51 | hg38,intervar_20180118,filter-based,InterVar: clinical interpretation of missense variants (indels not supported),20180325,Annovar 52 | hg18,cg46,filter-based,alternative allele frequency in 46 unrelated human subjects sequenced by Complete Genomics,20120222,Annovar 53 | hg19,cg46,filter-based,same as above,index updated 2012Feb22,Annovar 54 | hg18,cg69,filter-based,allele frequency in 69 human subjects sequenced by Complete Genomics,20120222,Annovar 55 | hg19,cg69,filter-based,same as above,20120222,Annovar 56 | hg19,cosmic64,filter-based,COSMIC database version 64,20130520,Annovar 57 | hg19,cosmic65,filter-based,COSMIC database version 65,20130706,Annovar 58 | hg19,cosmic67,filter-based,COSMIC database version 67,20131117,Annovar 59 | hg19,cosmic67wgs,filter-based,COSMIC database version 67 on WGS data,20131117,Annovar 60 | hg19,cosmic68,filter-based,COSMIC database version 68,20140224,Annovar 61 | hg19,cosmic68wgs,filter-based,COSMIC database version 68 on WGS data,20140224,Annovar 62 | hg19,cosmic70,filter-based,same as above,20140911,Annovar 63 | hg18,cosmic70,filter-based,same as above,20150428,Annovar 64 | hg38,cosmic70,filter-based,same as above,20150428,Annovar 65 | hg19/hg38,"cosmic71, 72, ..., 80",filter-based,read?here,,Annovar 66 | hg18,esp6500siv2_ea,filter-based,"alternative allele frequency in European American subjects in the NHLBI-ESP project with 6500 exomes, including the indel calls and the chrY calls. This is lifted over from hg19 by myself",20141222,Annovar 67 | hg19,esp6500siv2_ea,filter-based,same as above,20141222,Annovar 68 | hg38,esp6500siv2_ea,filter-based,"same as above, lifted over from hg19 by myself",20141222,Annovar 69 | hg18,esp6500siv2_aa,filter-based,"alternative allele frequency in African American subjects in the NHLBI-ESP project with 6500 exomes, including the indel calls and the chrY calls. This is lifted over from hg19 by myself.",20141222,Annovar 70 | hg19,esp6500siv2_aa,filter-based,same as above,20141222,Annovar 71 | hg38,esp6500siv2_aa,filter-based,"same as above, lifted over from hg19 by myself",20141222,Annovar 72 | hg18,esp6500siv2_all,filter-based,"alternative allele frequency in All subjects in the NHLBI-ESP project with 6500 exomes, including the indel calls and the chrY calls. This is lifted over from hg19 by myself.",20141222,Annovar 73 | hg19,esp6500siv2_all,filter-based,same as above,20141222,Annovar 74 | hg38,esp6500siv2_all,filter-based,"same as above, lifted over from hg19 by myself",20141222,Annovar 75 | hg19,exac03,filter-based,"ExAC 65000 exome allele frequency data for ALL, AFR (African), AMR (Admixed American), EAS (East Asian), FIN (Finnish), NFE (Non-finnish European), OTH (other), SAS (South Asian)). version 0.3. Left normalization done.",20151129,Annovar 76 | hg18,exac03,filter-based,same as above,20151129,Annovar 77 | hg38,exac03,filter-based,same as above,20151129,Annovar 78 | hg19,exac03nontcga,filter-based,ExAC on non-TCGA samples (updated header),20160423,Annovar 79 | hg38,exac03nontcga,filter-based,same as above,20160423,Annovar 80 | hg19,exac03nonpsych,filter-based,ExAC on non-Psychiatric disease samples (updated header),20160423,Annovar 81 | hg38,exac03nonpsych,filter-based,same as above,20160423,Annovar 82 | hg38,exac10,filter-based,No difference as exac03 based on?this; use exac03 instead,X,Annovar 83 | hg19,gene4denovo201907,filter-based,gene4denovo?database,20191101,Annovar 84 | hg38,gene4denovo201907,filter-based,gene4denovo database,20191101,Annovar 85 | hg19,gnomad_exome,filter-based,gnomAD exome collection (v2.0.1),20170311,Annovar 86 | hg38,gnomad_exome,filter-based,gnomAD exome collection (v2.0.1),20170311,Annovar 87 | hg19,gnomad_genome,filter-based,gnomAD genome collection (v2.0.1),20170311,Annovar 88 | hg38,gnomad_genome,filter-based,gnomAD genome collection (v2.0.1),20170311,Annovar 89 | hg19,gnomad211_exome,filter-based,"gnomAD exome collection (v2.1.1), with ""AF AF_popmax AF_male AF_female AF_raw AF_afr AF_sas AF_amr AF_eas AF_nfe AF_fin AF_asj AF_oth non_topmed_AF_popmax non_neuro_AF_popmax non_cancer_AF_popmax controls_AF_popmax"" header",20190318,Annovar 90 | hg19,gnomad211_genome,filter-based,same as above,20190323,Annovar 91 | hg38,gnomad211_exome,filter-based,same as above,20190409,Annovar 92 | hg38,gnomad211_genome,filter-based,same as above,20190409,Annovar 93 | hg38,gnomad30_genome,filter-based,version 3.0 whole-genome data,20191104,Annovar 94 | hg38,gnomad312_genome,filter-based,version 3.1.2 whole-genome data,20221228,Annovar 95 | hg19,kaviar_20150923,filter-based,170 million Known VARiants from 13K genomes and 64K exomes in 34 projects,20151203,Annovar 96 | hg38,kaviar_20150923,filter-based,same as above,20151203,Annovar 97 | hg19,hrcr1,filter-based,40 million variants from 32K samples in haplotype reference consortium,20151203,Annovar 98 | hg38,hrcr1,filter-based,same as above,20151203,Annovar 99 | hg19,abraom,filter-based,2.3 million?Brazilian genomic variants,20181204,Annovar 100 | hg38,abraom,filter-based,liftOver from above,20181204,Annovar 101 | hg18,1000g (3 data sets),filter-based,alternative allele frequency data in 1000 Genomes Project,20120222,Annovar 102 | hg18,1000g2010 (3 data sets),filter-based,same as above,20120222,Annovar 103 | hg18,1000g2010jul (3 data sets),filter-based,same as above,20120222,Annovar 104 | hg18,1000g2012apr,filter-based,"I lifted over the latest 1000 Genomes Project data to hg18, to help researchers working with hg18 coordinates",20120820,Annovar 105 | hg19,1000g2010nov,filter-based,same as above,20120222,Annovar 106 | hg19,1000g2011may,filter-based,same as above,20120222,Annovar 107 | hg19,1000g2012feb,filter-based,same as above,20130308,Annovar 108 | hg18,1000g2012apr (5 data sets),filter-based,"This is done by liftOver of the hg19 data below. It contains alternative allele frequency data in 1000 Genomes Project for ALL, AMR (admixed american), EUR (european), ASN (asian), AFR (african) populations",20130508,Annovar 109 | hg19,1000g2012apr (5 data sets),filter-based,"alternative allele frequency data in 1000 Genomes Project for ALL, AMR (admixed american), EUR (european), ASN (asian), AFR (african) populations",20120525,Annovar 110 | hg19,1000g2014aug (6 data sets),filter-based,"alternative allele frequency data in 1000 Genomes Project for autosomes (ALL, AFR (African), AMR (Admixed American), EAS (East Asian), EUR (European), SAS (South Asian)). Based on 201408 collection v4 (based on 201305 alignment)",20140915,Annovar 111 | hg19,1000g2014sep (6 data sets),filter-based,"alternative allele frequency data in 1000 Genomes Project for autosomes (ALL, AFR (African), AMR (Admixed American), EAS (East Asian), EUR (European), SAS (South Asian)). Based on 201409 collection v5 (based on 201305 alignment)",20140925,Annovar 112 | hg19,1000g2014oct (6 data sets),filter-based,"alternative allele frequency data in 1000 Genomes Project for autosomes (ALL, AFR (African), AMR (Admixed American), EAS (East Asian), EUR (European), SAS (South Asian)). Based on 201409 collection v5 (based on 201305 alignment) but including chrX and chrY data finally!",20141216,Annovar 113 | hg18,1000g2014oct (6 data sets),filter-based,same as above,20150428,Annovar 114 | hg38,1000g2014oct (6 data sets),filter-based,same as above,20150424,Annovar 115 | hg19,1000g2015aug (6 data sets),filter-based,The 1000G team fixed a bug in chrX frequency calculation. Based on 201508 collection v5b (based on 201305 alignment),20150824,Annovar 116 | hg38,1000g2015aug (6 data sets),filter-based,same as above,20150824,Annovar 117 | hg19,gme,filter-based,"Great Middle East?allele frequency including NWA (northwest Africa), NEA (northeast Africa), AP (Arabian peninsula), Israel, SD (Syrian desert), TP (Turkish peninsula) and CA (Central Asia)",20161024,Annovar 118 | hg38,gme,filter-based,same as above,20161024,Annovar 119 | hg19,mcap,filter-based,M-CAP scores?for non-synonymous variants,20161104,Annovar 120 | hg38,mcap,filter-based,same as above,20161104,Annovar 121 | hg19,mcap13,filter-based,[M-CAP scores v1.3],20181203,Annovar 122 | hg19,revel,filter-based,REVEL scores?for non-synonymous variants,20161205,Annovar 123 | hg38,revel,filter-based,same as above,20161205,Annovar 124 | hg18,snp128,filter-based,dbSNP with ANNOVAR index files,20120222,Annovar 125 | hg18,snp129,filter-based,same as above,20120222,Annovar 126 | hg19,snp129,filter-based,liftover from hg18_snp129.txt,20120809,Annovar 127 | hg18,snp130,filter-based,same as above,20120222,Annovar 128 | hg19,snp130,filter-based,same as above,20120222,Annovar 129 | hg18,snp131,filter-based,same as above,20120222,Annovar 130 | hg19,snp131,filter-based,same as above,20120222,Annovar 131 | hg18,snp132,filter-based,same as above,20120222,Annovar 132 | hg19,snp132,filter-based,same as above,20120222,Annovar 133 | hg18,snp135,filter-based,I lifted over SNP135 to hg18,20120820,Annovar 134 | hg19,snp135,filter-based,same as above,20120222,Annovar 135 | hg19,snp137,filter-based,same as above,20130109,Annovar 136 | hg18,snp138,filter-based,I lifted over SNP138 to hg18,20140910,Annovar 137 | hg19,snp138,filter-based,same as above,file and index updated 20140910,Annovar 138 | hg19,avsnp138,filter-based,dbSNP138 with allelic splitting and left-normalization,20141223,Annovar 139 | hg19,avsnp142,filter-based,dbSNP142 with allelic splitting and left-normalization,20141228,Annovar 140 | hg19,avsnp144,filter-based,dbSNP144 with allelic splitting and left-normalization (careful with?bugs!),20151102,Annovar 141 | hg38,avsnp144,filter-based,same as above,20151102,Annovar 142 | hg19,avsnp147,filter-based,dbSNP147 with allelic splitting and left-normalization,20160606,Annovar 143 | hg38,avsnp142,filter-based,dbSNP142 with allelic splitting and left-normalization,20160106,Annovar 144 | hg38,avsnp144,filter-based,dbSNP144 with allelic splitting and left-normalization,20151102,Annovar 145 | hg38,avsnp147,filter-based,dbSNP147 with allelic splitting and left-normalization,20160606,Annovar 146 | hg19,avsnp150,filter-based,dbSNP150 with allelic splitting and left-normalization,20170929,Annovar 147 | hg38,avsnp150,filter-based,dbSNP150 with allelic splitting and left-normalization,20170929,Annovar 148 | hg18,snp128NonFlagged,filter-based,"dbSNP with ANNOVAR index files, after removing those flagged SNPs (SNPs < 1% minor allele frequency (MAF) (or unknown), mapping only once to reference assembly, flagged in dbSnp as ""clinically associated"")",20120524,Annovar 149 | hg18,snp129NonFlagged,filter-based,same as above,20120524,Annovar 150 | hg18,snp130NonFlagged,filter-based,same as above,20120524,Annovar 151 | hg19,snp130NonFlagged,filter-based,same as above,20120524,Annovar 152 | hg18,snp131NonFlagged,filter-based,same as above,20120524,Annovar 153 | hg19,snp131NonFlagged,filter-based,same as above,20120524,Annovar 154 | hg18,snp132NonFlagged,filter-based,same as above,20120524,Annovar 155 | hg19,snp132NonFlagged,filter-based,same as above,20120524,Annovar 156 | hg19,snp135NonFlagged,filter-based,same as above,20120524,Annovar 157 | hg19,snp137NonFlagged,filter-based,same as above,20130109,Annovar 158 | hg19,snp138NonFlagged,filter-based,same as above,20140222,Annovar 159 | hg19,nci60,filter-based,NCI-60 human tumor cell line panel exome sequencing allele frequency data,20130724,Annovar 160 | hg18,nci60,filter-based,same as above,20150428,Annovar 161 | hg38,nci60,filter-based,same as above,20150428,Annovar 162 | hg19,icgc21,filter-based,International Cancer Genome Consortium version 21,20160622,Annovar 163 | hg19,icgc28,filter-based,International Cancer Genome Consortium version 28,20210122,Annovar 164 | hg38,icgc28,filter-based,International Cancer Genome Consortium version 28,20210122,Annovar 165 | hg19,clinvar_20131105,filter-based,"CLINVAR database with Variant Clinical Significance (unknown, untested, non-pathogenic, probable-non-pathogenic, probable-pathogenic, pathogenic, drug-response, histocompatibility, other) and Variant disease name",20140430,Annovar 166 | hg19,clinvar_20140211,filter-based,same as above,20140430,Annovar 167 | hg19,clinvar_20140303,filter-based,same as above,20140430,Annovar 168 | hg19,clinvar_20140702,filter-based,same as above,20140712,Annovar 169 | hg38,clinvar_20140702,filter-based,same as above,20140712,Annovar 170 | hg19,clinvar_20140902,filter-based,same as above,20140911,Annovar 171 | hg38,clinvar_20140902,filter-based,same as above,20140911,Annovar 172 | hg19,clinvar_20140929,filter-based,same as above,20141002,Annovar 173 | hg19,clinvar_20150330,filter-based,same as above but with variant normalization,20150413,Annovar 174 | hg38,clinvar_20150330,filter-based,same as above but with variant normalization,20150413,Annovar 175 | hg19,clinvar_20150629,filter-based,same as above but with variant normalization,20150724,Annovar 176 | hg38,clinvar_20150629,filter-based,same as above but with variant normalization,20150724,Annovar 177 | hg19,clinvar_20151201,filter-based,Clinvar version 20151201 with separate columns (CLINSIG CLNDBN CLNACC CLNDSDB CLNDSDBID),20160303,Annovar 178 | hg38,clinvar_20151201,filter-based,same as avove,20160303,Annovar 179 | hg19,clinvar_20160302,filter-based,Clinvar version 20160302 with separate columns (CLINSIG CLNDBN CLNACC CLNDSDB CLNDSDBID),20171003,Annovar 180 | hg38,clinvar_20160302,filter-based,same as above (updated 20171003 to handle multi-allelic variants),20171003,Annovar 181 | hg19,clinvar_20161128,filter-based,Clinvar version 20161128 with separate columns (CLINSIG CLNDBN CLNACC CLNDSDB CLNDSDBID),20171003,Annovar 182 | hg38,clinvar_20161128,filter-based,same as above (updated 20170215 to add missing header line; 20171003 to handle multi-allelic variants),20171003,Annovar 183 | hg19,clinvar_20170130,filter-based,Clinvar version 20170130 with separate columns (CLINSIG CLNDBN CLNACC CLNDSDB CLNDSDBID),20171003,Annovar 184 | hg38,clinvar_20170130,filter-based,same as above,20171003,Annovar 185 | hg19,clinvar_20170501,filter-based,Clinvar version 20170130 with separate columns (CLINSIG CLNDBN CLNACC CLNDSDB CLNDSDBID),20171003,Annovar 186 | hg38,clinvar_20170501,filter-based,same as above,20171003,Annovar 187 | hg19,clinvar_20170905,filter-based,Clinvar version 20170905 with separate columns (CLINSIG CLNDBN CLNACC CLNDSDB CLNDSDBID),20171003,Annovar 188 | hg38,clinvar_20170905,filter-based,same as above,20171003,Annovar 189 | hg19,clinvar_20180603,filter-based,Clinvar version 20180603 with separate columns (CLNALLELEID CLNDN CLNDISDB CLNREVSTAT CLNSIG),20180708,Annovar 190 | hg38,clinvar_20180603,filter-based,same as above,20180708,Annovar 191 | hg19,clinvar_20190305,filter-based,Clinvar version 20190305 with separate columns (CLNALLELEID CLNDN CLNDISDB CLNREVSTAT CLNSIG),20190311,Annovar 192 | hg38,clinvar_20190305,filter-based,same as above,20190316,Annovar 193 | hg19,clinvar_20200316,filter-based,Clinvar version 20200316 with separate columns (CLNALLELEID CLNDN CLNDISDB CLNREVSTAT CLNSIG),20200401,Annovar 194 | hg38,clinvar_20200316,filter-based,same as above,20200401,Annovar 195 | hg19,clinvar_20210123,filter-based,Clinvar version 20210123 with separate columns (CLNALLELEID CLNDN CLNDISDB CLNREVSTAT CLNSIG),20210202,Annovar 196 | hg38,clinvar_20210123,filter-based,same as above,20210202,Annovar 197 | hg19,clinvar_20210501,filter-based,Clinvar version 20210501 with separate columns (CLNALLELEID CLNDN CLNDISDB CLNREVSTAT CLNSIG),20210507,Annovar 198 | hg38,clinvar_20210501,filter-based,same as above,20210507,Annovar 199 | hg19,clinvar_20220320,filter-based,Clinvar version 20220320 with separate columns (CLNALLELEID CLNDN CLNDISDB CLNREVSTAT CLNSIG),20220330,Annovar 200 | hg38,clinvar_20220320,filter-based,same as above,20220320,Annovar 201 | hg19,clinvar_20221231,filter-based,Clinvar version 20221231 with separate columns (CLNALLELEID CLNDN CLNDISDB CLNREVSTAT CLNSIG),20230105,Annovar 202 | hg38,clinvar_20221231,filter-based,same as above,20230105,Annovar 203 | hg19,popfreq_max_20150413,filter-based,"A database containing the maximum allele frequency from 1000G, ESP6500, ExAC and CG46",20150413,Annovar 204 | hg19,popfreq_all_20150413,filter-based,"A database containing all allele frequency from 1000G, ESP6500, ExAC and CG46",20150413,Annovar 205 | hg19,mitimpact2,filter-based,pathogenicity predictions of human mitochondrial missense variants (see?here,20150520,Annovar 206 | hg19,mitimpact24,filter-based,same as above with version 2.4,20160123,Annovar 207 | hg19,regsnpintron,filter-based,prioritize the disease-causing probability of intronic SNVs,20180920,Annovar 208 | hg38,regsnpintron,filter-based,lifeOver of above,20180922,Annovar 209 | -------------------------------------------------------------------------------- /inst/Annovar/convert2annovar.pl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/123xiaochen/VCFshiny/f0f451c2ea4f2733ca89eebac98e360997c60298/inst/Annovar/convert2annovar.pl -------------------------------------------------------------------------------- /inst/Annovar/retrieve_seq_from_fasta.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | use warnings; 3 | use strict; 4 | use Getopt::Long; 5 | use Pod::Usage; 6 | use File::Spec; 7 | 8 | our $REVISION = '$Revision: 87c3b171d31838bb2b442ece9594c0ab79d1bc4d $'; 9 | our $DATE = '$Date: 2020-06-07 23:56:37 -0400 (Sun, 7 Jun 2020) $'; 10 | our $AUTHOR = '$Author: Kai Wang $'; 11 | 12 | our ($verbose, $help, $man); 13 | our ($regionfile); 14 | our ($outfile, $format, $seqdir, $seqfile, $tabout, $altchr, $addchr); 15 | our $localtime = localtime; 16 | 17 | GetOptions('verbose'=>\$verbose, 'help|h'=>\$help, 'man'=>\$man, 'outfile=s'=>\$outfile, 'format=s'=>\$format, 'seqdir=s'=>\$seqdir, 'seqfile=s'=>\$seqfile, 18 | 'tabout'=>\$tabout, 'altchr'=>\$altchr, 'addchr!'=>\$addchr) or pod2usage (); 19 | 20 | $help and pod2usage (-verbose=>1, -exitval=>1, -output=>\*STDOUT); 21 | $man and pod2usage (-verbose=>2, -exitval=>1, -output=>\*STDOUT); 22 | @ARGV or pod2usage (-verbose=>0, -exitval=>1, -output=>\*STDOUT); 23 | @ARGV == 1 or pod2usage ("Syntax error"); 24 | 25 | my $path = $0; 26 | $path =~ s/[^\\\/]+$//; 27 | $path and $ENV{PATH} = "$path:$ENV{PATH}"; #set up the system executable path to include the path where this program is located in 28 | $verbose and print STDERR "NOTICE: Adding $path into system executable path\n"; 29 | 30 | ($regionfile) = @ARGV; 31 | if (not defined $format) { 32 | $format = 'tab'; 33 | print STDERR "NOTICE: The default regionfile format is set as 'tab'\n"; 34 | } 35 | if (not defined $outfile) { 36 | $outfile = "$regionfile.fa"; 37 | print STDERR "NOTICE: The output file is written to $outfile (use --outfile to change this)\n"; 38 | } 39 | if ($outfile ne 'stdout') { 40 | open (STDOUT, ">$outfile") or die "Error: cannot write to output file $outfile: $!\n"; 41 | } 42 | 43 | $format =~ m/^(refGene|knownGene|ensGene|genericGene|tab|simple)$/ or pod2usage ("Error in argument: the --format argument can be only 'refGene', 'knownGene', 'ensGene', 'genericGene', 'tab' or 'simple'"); 44 | 45 | if (not defined $addchr) { 46 | $addchr = 1; #by default add chr prefix to region 47 | } 48 | 49 | my ($allregion, $allchr, $sorted_region) = readAllRegion ($regionfile, $format); 50 | 51 | my %seqhash; #database sequence for each chromosome 52 | my %name_seq; #sequence for each region 53 | my (%seqlen, %discordlen, %badorf); #store the length of each sequence, and the ID of sequences with discordant length, ORF contains stop codon 54 | my ($count_success, @failure) = (0); 55 | for my $curchr (sort keys %$allchr) { 56 | my ($seqid, $curseq) = ('', ''); 57 | my $fastafile; 58 | 59 | if ($seqfile) { #if the user specify the actual sequence file, the program will read directly from this file 60 | $fastafile = $seqfile; 61 | } else { #otherwise, the program will read from chr1.fa, chr2.fa, chr3.fa, etc. 62 | %seqhash = (); #clear the seqhash storage 63 | 64 | if ($curchr =~ m/^chr/) { 65 | $fastafile = File::Spec->catfile($seqdir, "$curchr.fa"); #by default, all FASTA files should be saved at fastadir, with the same name 66 | } else { 67 | $fastafile = File::Spec->catfile($seqdir, "chr$curchr.fa"); 68 | } 69 | 70 | if (not -e $fastafile) { 71 | $fastafile = File::Spec->catfile($seqdir, "$curchr.fa"); #zebrafish has chromosome names such as Zv9_scaffold3534.fa without chr prefix 72 | } 73 | 74 | if (not -e $fastafile) { 75 | $fastafile = File::Spec->catfile($seqdir, "softMask", "$curchr.fa"); #rheMac2 has this directory configuration 76 | } 77 | 78 | if (not -e $fastafile) { 79 | if ($curchr =~ m/^chr/) { 80 | my $curchr1 = $curchr; 81 | $curchr1 =~ s/^chr//; 82 | $curchr1 =~ s/_random$//; #the chr6_random.fa file will be saved in the 6/ directory 83 | $fastafile = File::Spec->catfile($seqdir, $curchr1, "$curchr.fa"); #panTro2_seq has this directory configuration 84 | } 85 | } 86 | if (not -e $fastafile) { #to handle cases where no "chr" prefix is given 87 | print STDERR "WARNING: the FASTA file $curchr.fa cannot be retrieved from the specified directory $seqdir. Sequences in this chromosome will not be processed\n"; 88 | next; 89 | } 90 | } 91 | 92 | if (not %seqhash) { 93 | open (FASTA, $fastafile) or print STDERR "WARNING: cannot read from FASTA file $fastafile so sequences in $curchr will not be processed: $!\n" and next; 94 | while () { 95 | if (m/^>(\S+)/) { 96 | $seqid and $seqhash{$seqid} = $curseq; #finish reading the sequence for seqid and save it 97 | $seqid = $1; 98 | $curseq = ''; 99 | } else { 100 | s/[\r\n]+$//; 101 | $curseq .= uc $_; #only use upper case characters 102 | } 103 | } 104 | $seqhash{$seqid} = $curseq; 105 | } 106 | 107 | if (not $seqhash{$curchr}) { #this chromosome just do not have FASTA sequences (maybe users used a wrong seqdir 108 | print STDERR "WARNING: Unable to retrieve regions at $curchr due to lack of sequence information\n"; 109 | next; 110 | } 111 | 112 | print STDERR "NOTICE: Finished reading ", scalar keys %seqhash, " sequences from $fastafile\n"; 113 | 114 | for my $i (0 .. @{$allregion->{$curchr}}-1) { 115 | my ($name, $start, $end, $strand, $exonpos, $mrnastart, $mrnaend) = @{$allregion->{$curchr}[$i]}; 116 | my @start = split (/,/, $start); 117 | my @end = split (/,/, $end); 118 | my $seq; 119 | for my $i (0..@start-1){ 120 | if ($start[$i] >= length ($seqhash{$curchr})) { #here there must be an annotation error in user-specified gene/region definition file 121 | print STDERR "WARNING: Ignoring the start position start=$start[$i] since it is longer than the $curchr sequence (length=" , length($seqhash{$curchr}), ")\n"; 122 | undef $seq; 123 | last; 124 | } 125 | $seq .= substr ($seqhash{$curchr}, $start[$i], $end[$i]-$start[$i]); 126 | } 127 | if ($strand eq '-' and defined $seq) { 128 | $seq = reverse $seq; 129 | $seq =~ tr/acgtACGT/tgcaTGCA/; 130 | } 131 | if (defined $seq) { 132 | if (defined $seqlen{$name}) { 133 | $seqlen{$name} != length ($seq) and $verbose and warn "WARNING: the sequence $name was found more than once with different sequence lengths\n"; 134 | $seqlen{$name} != length ($seq) and $discordlen{$name}++; 135 | } else { 136 | $seqlen{$name} = length ($seq); 137 | } 138 | #if ($tabout) { 139 | # print $name, "\t", $seq, "\n"; 140 | #} else { 141 | # if ($seqdir) { 142 | # print ">$name ", $discordlen{$name}?"Warning: $name occur more than once in file with discordant length. ":"", "Comment: this sequence (leftmost exon at $curchr:$start[0]) is generated by ANNOVAR on $localtime, based on regions specified in $regionfile and sequence files stored at $seqdir.\n$seq\n"; 143 | # } else { 144 | # print ">$name ", $discordlen{$name}?"Warning: $name occur more than once in file with discordant length. ":"", "Comment: this sequence (leftmost exon at $curchr:$start[0]) is generated by ANNOVAR on $localtime, based on regions specified in $regionfile and the sequence file $seqfile.\n$seq\n"; 145 | # } 146 | #} 147 | $name_seq{$name, $exonpos} = $seq; #added 2011feb19 148 | $count_success++; 149 | 150 | if (defined $mrnastart and defined $mrnaend) { 151 | my $dna = substr ($seq, $mrnastart-1, $mrnaend-$mrnastart+1); 152 | my $protein = translateDNA ($dna); 153 | if ($protein =~ m/\*\w/) { 154 | $verbose and print STDERR "WARNING: Potential FASTA sequence error for $name (ORF with premature stop codon)!!!\n"; 155 | $badorf{$name, $exonpos}++; 156 | } 157 | } 158 | } else { 159 | print STDERR "WARNING: DNA sequence for $name cannot be inferred\n"; 160 | push @failure, $name; 161 | } 162 | } 163 | } 164 | 165 | for my $i (0 .. @$sorted_region-1) { 166 | my ($name, $exonpos) = @{$sorted_region->[$i]}; 167 | if (not $name_seq{$name, $exonpos}) { 168 | print STDERR "WARNING: Cannot identify sequence for $name (starting from $exonpos)\n"; 169 | next; 170 | } 171 | 172 | if ($tabout) { 173 | print $name, "\t", $name_seq{$name, $exonpos}, "\n"; 174 | } else { 175 | print ">$name ", $discordlen{$name}?"Warning: $name occur more than once in file with discordant length. ":" ", $badorf{$name, $exonpos}?"Warning: this coding transcript does not have correct ORF annotation. ":" ", 176 | "Comment: this sequence (leftmost exon at $exonpos) is generated by ANNOVAR on $localtime, based on regions specified in $regionfile and ", $seqdir?"sequence files stored at $seqdir.\n":"the sequence file $seqfile.\n", 177 | $name_seq{$name, $exonpos}, "\n"; 178 | } 179 | } 180 | 181 | 182 | 183 | print STDERR "NOTICE: Finished writting FASTA for $count_success genomic regions to $outfile\n"; 184 | if (%discordlen) { 185 | my @discordlen = keys %discordlen; 186 | @discordlen = splice (@discordlen, 0, 5); 187 | print STDERR "WARNING: ${\(scalar keys %discordlen)} regions occur more than once with discordant sequence length (for example, ", join(", ", @discordlen), ")\n"; 188 | } 189 | if (%badorf) { 190 | my @badorf = keys %badorf; 191 | @badorf = splice (@badorf, 0, 5); 192 | print STDERR "WARNING: ${\(scalar keys %badorf)} gene regions do not have complete ORF (for example, ", join(", ", @badorf), ")\n"; 193 | } 194 | if (@failure) { 195 | print STDERR "WARNING: DNA sequences for ${\(scalar @failure)} regions cannot be inferred (see $outfile.failure for identifiers).\n"; 196 | open (FAILURE, ">$outfile.failure") or die "Error: cannot write to failure file $outfile.failure: $!\n"; 197 | print FAILURE join ("\n", @failure), "\n"; 198 | } 199 | 200 | sub translateDNA { 201 | my ($seq) = @_; 202 | my ($nt3, $protein); 203 | my %codon1 = (TTT=>"F", TTC=>"F", TCT=>"S", TCC=>"S", TAT=>"Y", TAC=>"Y", TGT=>"C", TGC=>"C", TTA=>"L", TCA=>"S", TAA=>"*", TGA=>"*", TTG=>"L", TCG=>"S", TAG=>"*", TGG=>"W", CTT=>"L", CTC=>"L", CCT=>"P", CCC=>"P", CAT=>"H", CAC=>"H", CGT=>"R", CGC=>"R", CTA=>"L", CTG=>"L", CCA=>"P", CCG=>"P", CAA=>"Q", CAG=>"Q", CGA=>"R", CGG=>"R", ATT=>"I", ATC=>"I", ACT=>"T", ACC=>"T", AAT=>"N", AAC=>"N", AGT=>"S", AGC=>"S", ATA=>"I", ACA=>"T", AAA=>"K", AGA=>"R", ATG=>"M", ACG=>"T", AAG=>"K", AGG=>"R", GTT=>"V", GTC=>"V", GCT=>"A", GCC=>"A", GAT=>"D", GAC=>"D", GGT=>"G", GGC=>"G", GTA=>"V", GTG=>"V", GCA=>"A", GCG=>"A", GAA=>"E", GAG=>"E", GGA=>"G", GGG=>"G"); 204 | 205 | $seq = uc $seq; 206 | #length ($seq) % 3 == 0 or printerr "WARNING: length of DNA sequence to be translated is not multiples of 3: \n"; 207 | while ($seq =~ m/(...)/g) { 208 | if (defined $codon1{$1}) { 209 | $protein .= $codon1{$1}; 210 | } else { 211 | $verbose and print STDERR "WARNING: invalid triplets found in DNA sequence to be translated: <$1> within <$seq>\n"; 212 | $protein .= "X"; 213 | } 214 | } 215 | return $protein; 216 | } 217 | 218 | sub readAllRegion { 219 | my ($regionfile, $format) = @_; 220 | my (@field, $name, $curchr, $start, $end, $strand); 221 | my (%allregion, %allchr, @sorted_region); #allregion is a hash with chr as key; allchr has chr as key; sorted_region is an array with name and linecount as elements 222 | my ($countregion, %counthap, $exonpos) = (0); 223 | if ($regionfile eq 'stdin') { 224 | *REGION = *STDIN; 225 | print STDERR "NOTICE: Reading region from STDIN ... "; 226 | } else { 227 | open (REGION, $regionfile) or die "Error: cannot read from regionfile $regionfile: $!\n"; 228 | print STDERR "NOTICE: Reading region file $regionfile ... "; 229 | } 230 | while () { 231 | s/[\r\n]+$//; 232 | $strand = '+'; 233 | my ($mrnastart, $mrnaend); 234 | if ($format eq 'knownGene' or $format eq 'refGene' or $format eq 'ensGene' or $format eq 'genericGene') { 235 | #example: 1475 NM_021648 chr6 - 116677823 116681954 116680619 116681864 1 116677823, 116681954, 0 TSPYL4 cmpl cmpl 0, 236 | @field = split (/\t/, $_); 237 | if ($format eq 'knownGene') { 238 | @field >= 11 or die "Error: invalid record found in '$format' file $regionfile (>=11 fields expected but found ${\(scalar @field)} fields): <$_>\n"; 239 | } elsif ($format eq 'refGene') { 240 | @field == 15 or @field == 16 or die "Error: invalid record found in '$format' file $regionfile (15 or 16 fields expected): <$_>\n"; 241 | shift @field if(@field==16); #shifting out the first field; 242 | } elsif ($format eq 'ensGene') { 243 | if (@field == 16) { #many organisms (yeast, etc) do not have ENS-prefixed gene names in ENSEMBL 244 | shift @field; 245 | } elsif (@field == 10) { 246 | 1; 247 | } else { 248 | die "Error: invalid record found in '$format' file $regionfile (16 or 10 fields expected but found ${\(scalar @field)}): <$_>\n"; 249 | } 250 | } elsif ($format eq 'genericGene') { 251 | @field >= 11 or die "Error: invalid record found in '$format' file $regionfile (>=11 fields expected but found ${\(scalar @field)} fields): <$_>\n"; 252 | shift @field; 253 | } 254 | 255 | $name = $field[0]; 256 | ($curchr, $start, $end) = @field[1,8,9]; 257 | $strand = $field[2]; 258 | $strand eq '+' or $strand eq '-' or die "Error: invalid strand designations in the region file $regionfile: <$_>\n"; 259 | 260 | if (not $altchr and $curchr =~ m/hap\d+$/) { #for example, chr5_h2_hap1, chr6_cox_hap1 261 | $counthap{$curchr}++; 262 | next; 263 | } 264 | $exonpos = "$curchr:$field[3]"; 265 | 266 | #the following paragraph was added 2011Nov12 to identify transcripts without complete coding information 267 | my ($txstart, $txend, $cdsstart, $cdsend) = @field[3, 4, 5, 6]; 268 | if ($cdsstart != $cdsend) { #this is a real protein coding gene by annotation 269 | my @exonstart = split (/,/, $start); 270 | my @exonend = split (/,/, $end); 271 | 272 | $txstart++; 273 | $cdsstart++; 274 | @exonstart = map {$_+1} @exonstart; 275 | if ($strand eq '+') { 276 | #<---->-----<--->----<------>----<----->-----<---> 277 | # ********** 278 | my $intron = 0; 279 | for my $i (0 .. @exonstart-1) { 280 | $i and $intron += ($exonstart[$i]-$exonend[$i-1]-1); 281 | if ($cdsstart >= $exonstart[$i] and $cdsstart <= $exonend[$i]) { 282 | $mrnastart = $cdsstart-$txstart+1-$intron; 283 | } 284 | if ($cdsend >= $exonstart[$i] and $cdsend <= $exonend[$i]) { 285 | $mrnaend = $cdsend-$txstart+1-$intron; 286 | } 287 | 288 | } 289 | } elsif ($strand eq '-') { 290 | #<---->-----<--->----<------>----<----->-----<---> 291 | # ********** 292 | my $intron = 0; 293 | for (my $i=@exonstart-1; $i>=0; $i--) { 294 | $i<@exonstart-1 and $intron += ($exonstart[$i+1]-$exonend[$i]-1); 295 | if ($cdsend >= $exonstart[$i] and $cdsend <= $exonend[$i]) { 296 | $mrnastart = $txend-$cdsend+1-$intron; 297 | } 298 | if ($cdsstart >= $exonstart[$i] and $cdsstart <= $exonend[$i]) { 299 | $mrnaend = $txend-$cdsstart+1-$intron; 300 | } 301 | 302 | } 303 | } 304 | } 305 | 306 | 307 | } elsif ($format eq 'tab') { 308 | #example: 1 1000 2000 309 | #example: chr1 1000 2000 310 | @field = split (/\t/, $_); 311 | @field >= 3 or die "Error: invalid record found in input file (at least 3 tab-delimited fields expected for '-format tab'): <$_>\n"; 312 | $field[1] =~ m/^\d+$/ and $field[2] =~ m/^\d+$/ or die "Error: invalid record found in input file (2nd and 3rd column should be positive integer for '-format tab': <$_> <$field[1]><$field[2]\n"; 313 | $name = "$field[0]:$field[1]-$field[2]"; 314 | ($curchr, $start, $end) = @field[0..2]; 315 | if (not $curchr =~ m/^chr/ and $addchr) { 316 | $curchr = "chr$curchr"; 317 | } 318 | 319 | $start--; #make zero-start coordinate, to be consistent with UCSC 320 | $exonpos = "$curchr:$start"; 321 | } elsif ($format eq 'simple') { 322 | #example: 1:1000-2000 323 | #example: chr1:1000-2000 324 | m/^((chr)?\w+):(\d+)\-(\d+)/ or die "Error: invalid record found in input line (chr:start-end expected): <$_>\n"; 325 | ($curchr, $start, $end) = ($1, $3, $4); 326 | if (not $curchr =~ m/^chr/ and $addchr) { 327 | $curchr = "chr$curchr"; 328 | } 329 | $name = "$curchr:$start-$end"; 330 | 331 | $start--; #make zero-start coordinate, to be consistent with UCSC 332 | $exonpos = "$curchr:$start"; 333 | } 334 | 335 | $allchr{$curchr}++; 336 | if (defined $mrnastart and defined $mrnaend) { 337 | push @{$allregion{$curchr}}, [$name, $start, $end, $strand, $exonpos, $mrnastart, $mrnaend]; 338 | } else { 339 | push @{$allregion{$curchr}}, [$name, $start, $end, $strand, $exonpos]; 340 | } 341 | push @sorted_region, [$name, $exonpos]; #these two elements uniquely identifies a sequence ID 342 | $countregion++; 343 | } 344 | print STDERR "Done with $countregion regions from ", scalar (keys %allchr), " chromosomes"; 345 | if (%counthap) { 346 | my @counthap = keys %counthap; 347 | if (@counthap > 5) { 348 | @counthap = splice (@counthap, 0, 3); 349 | print STDERR " (${\(scalar keys %counthap)} 'alternative haplotype' chromosomes are skipped, such as ", join (", ", @counthap), ", etc)\n"; 350 | } else { 351 | print STDERR " (${\(scalar keys %counthap)} 'alternative haplotype' chromosomes are skipped, including ", join (", ", @counthap), ")\n"; 352 | } 353 | } else { 354 | print STDERR "\n"; 355 | } 356 | return (\%allregion, \%allchr, \@sorted_region); 357 | } 358 | 359 | 360 | =head1 SYNOPSIS 361 | 362 | retrieve_seq_from_fasta.pl [arguments] 363 | 364 | Optional arguments: 365 | -v, --verbose use verbose output 366 | -h, --help print help message 367 | -m, --man print complete documentation 368 | --format format of the regionfile 369 | --outfile output file name (default: input.fa) 370 | --seqdir directory containing sequence files for genomes 371 | --seqfile sequence file name 372 | --tabout use tab-delimited output (default is FASTA file) 373 | --altchr process alternative haplotype chromosome (default: OFF) 374 | --[no]addchr add chr prefix to region specification (default: ON) 375 | 376 | Function: reformat sequences at specific genomic positions from whole-genome FASTA files 377 | 378 | Example: retrieve_seq_from_fasta.pl -format tab -seqdir humandb/ region.tabinput 379 | retrieve_seq_from_fasta.pl -format tab -seqfile chrall.fa region.tabinput 380 | retrieve_seq_from_fasta.pl -format simple -seqdir humandb/ region.input 381 | retrieve_seq_from_fasta.pl -format refGene -seqdir humandb hg18_refGenet.txt 382 | retrieve_seq_from_fasta.pl -format genericGene -seqdir humandb/ hg18_gencodeGene.txt 383 | 384 | Version:$Date: 2020-06-07 23:56:37 -0400 (Sun, 7 Jun 2020) $ 385 | 386 | =head1 OPTIONS 387 | 388 | =over 8 389 | 390 | =item B<--help> 391 | 392 | print a brief help message and exit 393 | 394 | =item B<--man> 395 | 396 | print the complete manual of how to use the program 397 | 398 | =item B<--verbose> 399 | 400 | use verbose output 401 | 402 | =item B<--format> 403 | 404 | specify the format of the input file (default: tab). Other supported formats 405 | include simple, refGene, knownGene, ensGene, genericGene and many other format 406 | support will be added in the future. 407 | 408 | =item B<--outfile> 409 | 410 | specify the output file name (default: .fa) 411 | 412 | =item B<--seqdir> 413 | 414 | specify the directory of the sequence files (usually these sequence files are 415 | organized by chromosomes, and that the file name represent the chromosome). 416 | 417 | =item B<--seqfile> 418 | 419 | specify the sequence file name (assuming that all sequences are stored within a 420 | single file). 421 | 422 | =item B<--tabout> 423 | 424 | use tab-delimited output. By default, FASTA file will be printed out. 425 | 426 | =item B<--altchr> 427 | 428 | process alternative haplotype chromosome, that look like chr6_cox_hap1. By 429 | default this will not be processed. 430 | 431 | =item B<--(no)addchr> 432 | 433 | add chr prefix to region if it is not present (default: ON) 434 | 435 | =back 436 | 437 | =head1 DESCRIPTION 438 | 439 | This program is designed for retrieving sequences at specific genomic regions 440 | from whole-genome FASTA files. These files should be saved at a specific 441 | directory, with one chromosome per file. 442 | 443 | The FASTA files can be easily downloaded automatically by the ANNOVAR software: 444 | 445 | annotate_variation.pl -buildver hg19 -downdb seq humandb/hg19_seq/ 446 | 447 | The FASTA files (one for each chromosome) will be saved at the humandb/hg19_seq/ 448 | directory. Users can then use the retrieve_seq_from_fasta.pl program to retrieve 449 | sequences from specific genomic regions in these chromosomes. 450 | 451 | Several region input files can be supported, via the -format argument: 452 | 453 | =over 8 454 | 455 | =item * B 456 | 457 | The simple format is something like chr1:200-3000, one region per line. 458 | 459 | =item * B 460 | 461 | the tab format is tab-delimited format, with first 3 columns as chr, start, end, 462 | at each line. 463 | 464 | =item * B 465 | 466 | the refgene format is provided by the UCSC Genome Browser, in the refGene.txt 467 | database annotation files. 468 | 469 | =item * B 470 | 471 | the knowngene format is provided by the UCSC Genome Browser, in the knownGene.txt 472 | database annotation files. 473 | 474 | =item * B 475 | 476 | the ensgene format is provided by the UCSC Genome Browser, in the ensGene.txt 477 | database annotation files. 478 | 479 | =back 480 | 481 | For questions, comments or bug reports, please contact me at 482 | $Author: Kai Wang $. 483 | 484 | =cut -------------------------------------------------------------------------------- /inst/Annovar/variants_reduction.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | use warnings; 3 | use strict; 4 | use Pod::Usage; 5 | use Getopt::Long; 6 | use File::Copy; 7 | use File::Basename; 8 | 9 | our $REVISION = '$Revision: a64f71073be44e295d1363669de039bd6ca0bebd $'; 10 | our $DATE = '$Date: 2019-10-24 00:05:28 -0400 (Thu, 24 Oct 2019) $'; 11 | our $AUTHOR = '$Author: Kai Wang $'; 12 | 13 | our ($verbose, $help, $man); 14 | our ($queryfile, $dbloc); 15 | our ($outfile, $buildver, $remove, $checkfile, $dispensable, $genetype, $aaf_threshold, $maf_threshold, $protocol, $operation, $genericdbfile, 16 | $ljb_sift_threshold, $ljb_pp2_threshold, $ljb2_sift_threshold, $ljb2_pp2hvar_threshold, $ljb2_pp2hdiv_threshold, $argument); 17 | 18 | GetOptions('verbose|v'=>\$verbose, 'help|h'=>\$help, 'man|m'=>\$man, 'outfile=s'=>\$outfile, 'buildver=s'=>\$buildver, 'remove'=>\$remove, 19 | 'checkfile!'=>\$checkfile, 'dispensable=s'=>\$dispensable, 'genetype=s'=>\$genetype, 'maf_threshold=f'=>\$maf_threshold, 20 | 'aaf_threshold=f'=>\$aaf_threshold, 'protocol=s'=>\$protocol, 'operation=s'=>\$operation, 'genericdbfile=s'=>\$genericdbfile, 21 | 'ljb_sift_threshold=f'=>\$ljb_sift_threshold, 'ljb_pp2_threshold=f'=>\$ljb_pp2_threshold, 'ljb2_sift_threshold=f'=>\$ljb_sift_threshold, 'ljb2_pp2hvar_threshold=f'=>\$ljb_pp2_threshold, 'ljb2_pp2hdiv_threshold=f'=>\$ljb2_pp2hdiv_threshold, 22 | 'argument=s'=>\$argument) or pod2usage (); 23 | 24 | $help and pod2usage (-verbose=>1, -exitval=>1, -output=>\*STDOUT); 25 | $man and pod2usage (-verbose=>2, -exitval=>1, -output=>\*STDOUT); 26 | @ARGV or pod2usage (-verbose=>0, -exitval=>1, -output=>\*STDOUT); 27 | @ARGV == 2 or pod2usage ("Syntax error"); 28 | 29 | 30 | ($queryfile, $dbloc) = @ARGV; 31 | 32 | $^O eq 'MSWin32' and die "Error: this program does not work in Microsoft Windows operating system\n"; 33 | 34 | #prepare PATH environmental variable 35 | my $path = File::Basename::dirname ($0); 36 | $path and $ENV{PATH} = "$path:$ENV{PATH}"; #set up the system executable path to include the path where this program is located in 37 | 38 | $outfile ||= $queryfile; 39 | $genetype ||= 'refgene'; 40 | $genetype =~ m/^refgene|knowngene|ensgene$/i or pod2usage ("Error in argument: the --genetype can be 'refgene', 'knowngene' or 'ensgene' only"); #20190509: I deleted gencodegene since ensGene is now the gencodegene 41 | 42 | 43 | if (not defined $buildver) { 44 | $buildver = 'hg18'; 45 | print STDERR "NOTICE: the --buildver argument is set as 'hg18' by default\n"; 46 | } 47 | 48 | if (defined $maf_threshold) { 49 | pod2usage ("Error in argument: the --maf_threshold is removed due to user complaints. Please use --aaf_threshold instead"); 50 | } 51 | 52 | 53 | if (defined $aaf_threshold) { 54 | $aaf_threshold >= 0 and $aaf_threshold <= 1 or pod2usage ("Error: the --aaf_threshold argument must be between 0 and 1 inclusive"); 55 | } 56 | 57 | not defined $checkfile and $checkfile = 1; 58 | 59 | if (not $protocol) { #kept here for backward compatibility 60 | $operation and pod2usage ("Error in argument: you must specify --protocol if you specify --operation"); 61 | if ($buildver eq 'hg18') { 62 | $protocol = 'nonsyn_splicing,1000g2010jul_ceu,1000g2010jul_jptchb,1000g2010jul_yri,snp132,esp5400_ea,esp5400_aa,recessive'; 63 | $operation = 'g,f,f,f,f,f,f,m'; 64 | print STDERR "NOTICE: the --protocol argument is set as 'nonsyn_splicing,1000g2010jul_ceu,1000g2010jul_jptchb,1000g2010jul_yri,snp132,esp5400_ea,esp5400_aa,recessive' by default\n"; 65 | } elsif ($buildver eq 'hg19') { 66 | $protocol = 'nonsyn_splicing,1000g2012apr_all,snp135NonFlagged,esp6500_ea,esp6500_aa,recessive'; 67 | $operation = 'g,f,f,f,f,m'; 68 | print STDERR "NOTICE: the --protocol argument is set as 'nonsyn_splicing,1000g2012apr_all,snp135NonFlagged,esp6500_ea,esp6500_aa,recessive' by default\n"; 69 | } elsif ($buildver eq 'hg38') { 70 | $protocol = 'nonsyn_splicing,1000g2015aug_all,snp142,esp6500siv2_all,esp6500siv2_ea,esp6500siv2_aa,recessive'; 71 | $operation = 'g,f,f,f,f,m'; 72 | print STDERR "NOTICE: the --protocol argument is set as 'nonsyn_splicing,1000g2015aug_all,snp142,esp6500siv2_all,esp6500siv2_ea,esp6500siv2_aa,recessive' by default\n"; 73 | } 74 | } 75 | 76 | if ($protocol =~ m/\bgeneric\b/) { 77 | $genericdbfile or pod2usage ("Error in argument: please specify -genericdbfile argument when 'generic' operation is specified"); 78 | } 79 | 80 | my @protocol = split (/,/, $protocol); 81 | my @operation = split (/,/, $operation); 82 | my @argument = split (/,/, $argument||'', -1); 83 | my $sc; 84 | my $linecount; 85 | 86 | my (%valistep, $skip); 87 | 88 | @protocol == @operation or pod2usage ("Error in argument: different number of elements are specified in --protocol and --operation argument"); 89 | @argument and @protocol == @argument || pod2usage ("Error in argument: different number of elements are specified in --protocol and --argument argument"); 90 | 91 | for my $op (@operation) { 92 | $op =~ m/^g|r|f|m|rr|fr$/ or pod2usage ("Error in argument: the --operation argument must be comma-separated list of 'g', 'r', 'f', 'rr', 'fr' or 'm'"); 93 | } 94 | 95 | $checkfile and checkFileExistence (); 96 | 97 | copy ($queryfile, "$outfile.step0.varlist"); 98 | for my $i (0 .. @protocol-1) { 99 | print STDERR "-----------------------------------------------------------------\n"; 100 | print STDERR "NOTICE: Processing operation=$operation[$i] protocol=$protocol[$i]\n"; 101 | if ($operation[$i] eq 'g') { 102 | geneOperation ($i+1, "$outfile.step$i.varlist", $protocol[$i], 0, $argument[$i]||undef); 103 | } elsif ($operation[$i] eq 'r') { 104 | regionOperation ($i+1, "$outfile.step$i.varlist", $protocol[$i], 0, $argument[$i]||undef); 105 | } elsif ($operation[$i] eq 'rr') { 106 | regionOperation ($i+1, "$outfile.step$i.varlist", $protocol[$i], 1, $argument[$i]||undef); 107 | } elsif ($operation[$i] eq 'f') { 108 | filterOperation ($i+1, "$outfile.step$i.varlist", $protocol[$i], 0, $argument[$i]||undef); 109 | } elsif ($operation[$i] eq 'fr') { 110 | filterOperation ($i+1, "$outfile.step$i.varlist", $protocol[$i], 1, $argument[$i]||undef); 111 | } elsif ($operation[$i] eq 'm') { 112 | modelOperation ($i+1, "$outfile.step$i.varlist", $protocol[$i], 0, $argument[$i]||undef); 113 | } 114 | } 115 | 116 | 117 | 118 | sub geneOperation { 119 | my ($step, $infile, $operation, $reverse, $arg) = @_; 120 | 121 | if ($operation eq 'nonsyn_splicing' or $operation eq 'nonsyn') { 122 | $sc = "annotate_variation.pl -geneanno -buildver $buildver -dbtype $genetype -outfile $outfile.step$step $infile $dbloc"; 123 | defined $arg and $sc .= " $arg"; 124 | print STDERR "\nNOTICE: Running step $step with system command <$sc>\n"; 125 | system ($sc) and die "Error running system command: <$sc>\n"; 126 | columnGrep ("$outfile.step$step.exonic_variant_function", "$outfile.step$step.varlist", '^(?:synonymous SNV|nonframeshift deletion|nonframeshift insertion|nonframeshift substitution)$', 2, "\t", 4, 'reverse'); 127 | 128 | if ($operation eq 'nonsyn_splicing') { 129 | columnGrep ("$outfile.step1.variant_function", "$outfile.step$step.varlist.temp", '\bsplicing\b', 1, "\t", 1); 130 | columnGrep ("$outfile.step$step.varlist.temp", "$outfile.step$step.varlist", '\bexonic\b', 1, "\t", 3, 'reverse', 'append'); 131 | } 132 | 133 | open (FH, "$outfile.step$step.varlist") or die "Error: cannot read from $outfile.step$step.varlist: $!\n"; 134 | open (FHOUT, ">$outfile.step$step.varlist.temp") or die "Error: cannot write to $outfile.step$step.varlist.temp: $!\n"; 135 | my %found; 136 | my $linecount=0; 137 | while () { 138 | $found{$_} and next; 139 | print FHOUT $_; 140 | $found{$_}++; 141 | $linecount++; 142 | } 143 | close (FH); 144 | close (FHOUT); 145 | move ("$outfile.step$step.varlist.temp", "$outfile.step$step.varlist"); 146 | 147 | #$remove and unlink ("$outfile.step$step.varlist"); 148 | 149 | $linecount or warn "WARNING: No variants were left in analysis after this step. Program exits.\n" and exit; 150 | print STDERR "NOTICE: After step $step, $linecount variants are left in analysis.\n"; 151 | } else { 152 | die "Error: the $operation command for gene-based annotation is currently not supported\n"; 153 | } 154 | } 155 | 156 | sub columnGrep { 157 | my ($infile, $outfile, $pattern, $column, $separator, $outcolumn, $reverse, $append) = @_; 158 | defined $column or die "Error: column to the columnGrep subroutine must be defined\n"; 159 | defined $separator or $separator = '\s+'; 160 | open (FHIN, $infile) or die "Error: cannot read from input file $infile: $!\n"; 161 | if ($append) { 162 | open (FHOUT, ">>$outfile") or die "Error: cannot append to output file $outfile: $!\n"; 163 | } else { 164 | open (FHOUT, ">$outfile") or die "Error: cannot write to output file $outfile: $!\n"; 165 | } 166 | while () { 167 | my @field = split (/$separator/, $_); 168 | if ($reverse) { 169 | $field[$column-1] =~ m/$pattern/ or print FHOUT join ($separator, @field[($outcolumn-1) .. $#field]); 170 | } else { 171 | $field[$column-1] =~ m/$pattern/ and print FHOUT join ($separator, @field[($outcolumn-1) .. $#field]); 172 | } 173 | } 174 | close (FHIN); 175 | close (FHOUT); 176 | } 177 | 178 | sub regionOperation { 179 | my ($step, $infile, $dbtype, $reverse, $arg) = @_; 180 | $sc = "annotate_variation.pl -regionanno -dbtype $dbtype -buildver $buildver -outfile $outfile.step$step $infile $dbloc"; 181 | defined $arg and $sc .= " $arg"; 182 | print STDERR "\nNOTICE: Running step $step with system command <$sc>\n"; 183 | system ($sc) and die "Error running system command: <$sc>\n"; 184 | if ($reverse) { 185 | system ("cut -f 3- $outfile.step$step.${buildver}_$dbtype > $outfile.step$step.temp"); 186 | system ("fgrep -v -f $outfile.step$step.temp $infile > $outfile.step$step.varlist"); 187 | } else { 188 | system ("cut -f 3- $outfile.step$step.${buildver}_$dbtype > $outfile.step$step.varlist"); 189 | } 190 | 191 | #$remove and unlink ("$outfile.step$step.varlist", "$outfile.step$step.${buildver}_$dbtype"); 192 | $linecount = qx/cat $outfile.step$step.varlist | wc -l/; chomp $linecount; 193 | $linecount or warn "WARNING: No variants were left in analysis after this step. Program exits.\n" and exit; 194 | print STDERR "NOTICE: After step $step, $linecount variants are left in analysis.\n"; 195 | } 196 | 197 | sub filterOperation { 198 | my ($step, $infile, $dbtype, $reverse, $arg) = @_; 199 | $sc = "annotate_variation.pl -filter -dbtype $dbtype -buildver $buildver -outfile $outfile.step$step $infile $dbloc"; 200 | defined $arg and $sc .= " $arg"; 201 | 202 | if ($dbtype eq 'generic') { 203 | $sc .= " -genericdbfile $genericdbfile"; 204 | } 205 | 206 | if ($reverse) { 207 | $sc .= " -reverse"; 208 | } 209 | 210 | if ($dbtype eq 'ljb_sift') { 211 | my $score_threshold = $ljb_sift_threshold || 0.95; 212 | $sc .= " -score_threshold $score_threshold -reverse"; 213 | } 214 | 215 | if ($dbtype eq 'ljb_pp2') { 216 | my $score_threshold = $ljb_pp2_threshold || 0.85; 217 | $sc .= " -score_threshold $score_threshold -reverse"; 218 | } 219 | 220 | if ($dbtype =~ m/ljb2\d*_sift/) { 221 | my $score_threshold = $ljb2_sift_threshold || 0.05; 222 | $sc .= " -score_threshold $score_threshold"; 223 | } 224 | 225 | if ($dbtype =~ m/ljb2\d*_pp2hdiv/) { 226 | my $score_threshold = $ljb2_pp2hdiv_threshold || 0.957; 227 | $sc .= " -score_threshold $score_threshold -reverse"; 228 | } 229 | 230 | if ($dbtype =~ m/ljb2\d*_pp2hvar/) { 231 | my $score_threshold = $ljb2_pp2hvar_threshold || 0.909; 232 | $sc .= " -score_threshold $score_threshold -reverse"; 233 | } 234 | 235 | if (defined $aaf_threshold) { 236 | if ($dbtype =~ m/^1000g/ or $dbtype =~ m/^esp\d+/ or $dbtype =~ m/^cg\d+/ or $dbtype =~ m/^exac\d+/ or $dbtype =~ m/^gnomad/) { 237 | $sc .= " -score_threshold $aaf_threshold"; 238 | } 239 | } 240 | 241 | 242 | print STDERR "\nNOTICE: Running step $step with system command <$sc>\n"; 243 | system ($sc) and die "Error running system command: <$sc>\n"; 244 | 245 | my $dbtype1 = $dbtype; 246 | if ($dbtype =~ m/^1000g_(\w+)/) { 247 | $dbtype1 = uc ($1) . ".sites.2009_04"; 248 | } elsif ($dbtype =~ m/^1000g2010_(\w+)/) { 249 | $dbtype1 = uc ($1) . ".sites.2010_03"; 250 | } elsif ($dbtype =~ m/^1000g(20\d\d)([a-z]{3})_([a-z]+)$/) { 251 | my %monthhash = ('jan'=>'01', 'feb'=>'02', 'mar'=>'03', 'apr'=>'04', 'may'=>'05', 'jun'=>'06', 'jul'=>'07', 'aug'=>'08', 'sep'=>'09', 'oct'=>'10', 'nov'=>'11', 'dec'=>'12'); 252 | $dbtype1 = uc ($3) . ".sites.$1" . '_' . $monthhash{$2}; 253 | } 254 | 255 | copy ("$outfile.step$step.${buildver}_${dbtype1}_filtered", "$outfile.step$step.varlist"); #use dbtype1, not dbtype!!! 256 | 257 | #$remove and unlink ("$outfile.step$step.varlist", "$outfile.step$step.${dbtype}_filtered", "$outfile.step$step.${dbtype}_dropped"); 258 | $linecount = qx/cat $outfile.step$step.varlist | wc -l/; chomp $linecount; 259 | $linecount or warn "WARNING: No variants were left in analysis after this step. Program exits.\n" and exit; 260 | print STDERR "NOTICE: After step $step, $linecount variants are left in analysis.\n"; 261 | } 262 | 263 | sub modelOperation { 264 | my ($step, $infile, $dbtype, $reverse, $arg) = @_; 265 | $sc = "fgrep -f $infile $outfile.step1.exonic_variant_function | fgrep -v -w UNKNOWN | cut -f 2- > $outfile.step$step.varlist;"; #function, gene name, plus original input 266 | $sc .= "cut -f 3- $outfile.step$step.varlist > $outfile.step$step.temp;"; #list of all avinput 267 | $sc .= "fgrep -v -f $outfile.step$step.temp $infile > $outfile.step$step.temp1;"; #list of splicing variants 268 | $sc .= "fgrep -f $outfile.step$step.temp1 $outfile.step1.variant_function | fgrep splicing >> $outfile.step$step.varlist;"; #adding splicing variants to nonsyn variants 269 | print STDERR "\nNOTICE: Running step $step with system command <$sc>\n"; 270 | system ($sc); #this command may generate error, because the $outfile.step8.temp1 file may be empty 271 | 272 | $remove and unlink ("$outfile.step$step.temp", "$outfile.step$step.temp1", "$outfile.step1.exonic_variant_function"); 273 | 274 | 275 | my (%found, %varpos); #count of gene, variant information of the variant 276 | open (VAR, "$outfile.step$step.varlist") or die "Error: cannot read from varlist file $outfile.step$step.varlist: $!\n"; 277 | while () { 278 | my @field = split (/\t/, $_); 279 | $field[1] =~ s/,$//; 280 | 281 | #$field[1] =~ s/\([^\(\)]+\)//g; #handle situations such as splicing EMG1(NM_006331:exon1:c.125+1T>GC,NM_006331:exon2:c.126-1T>GC) 282 | 283 | $field[1] =~ m/^(\w+)/ or die "Error: invalid record in input file $outfile.step$step.varlist (gene name expected at second column): <$_>\n"; 284 | my $gene = $1; 285 | $found{$gene}++; 286 | $varpos{$gene} .= "\t$field[1]"; 287 | if (m/\bhom\b/) { 288 | $found{$gene}++; 289 | } 290 | } 291 | 292 | my $count_candidate_gene = 0; 293 | open (OUT, ">$outfile.step$step.genelist") or die "Error: cannot write to output file $outfile.step$step.genelist: $!\n"; 294 | print OUT "Gene\tNumber_of_deleterious_alleles\tMutations\n"; 295 | for my $key (keys %found) { 296 | if ($dbtype eq 'recessive') { 297 | if ($found{$key} >= 2) { 298 | print OUT "$key\t$found{$key}$varpos{$key}\n"; 299 | $count_candidate_gene++; 300 | } 301 | } elsif ($dbtype eq 'dominant') { 302 | if ($found{$key} >= 1) { 303 | print OUT "$key\t$found{$key}$varpos{$key}\n"; 304 | $count_candidate_gene++; 305 | } 306 | } else { 307 | die "Error: the model operation $dbtype specified in -operation argument is not supported\n"; 308 | } 309 | } 310 | print STDERR "\nNOTICE: a list of $count_candidate_gene potentially important genes and the number of deleterious alleles in them are written to $outfile.step$step.genelist\n"; 311 | } 312 | 313 | sub checkFileExistence { 314 | my @file; 315 | my %dbtype1 = ('gene'=>'refGene', 'refgene'=>'refGene', 'knowngene'=>'knownGene', 'ensgene'=>'ensGene', 'band'=>'cytoBand', 'cytoband'=>'cytoBand', 'tfbs'=>'tfbsConsSites', 'mirna'=>'wgRna', 316 | 'mirnatarget'=>'targetScanS', 'segdup'=>'genomicSuperDups', 'omimgene'=>'omimGene', 'gwascatalog'=>'gwasCatalog', 317 | '1000g_ceu'=>'CEU.sites.2009_04', '1000g_yri'=>'YRI.sites.2009_04', '1000g_jptchb'=>'JPTCHB.sites.2009_04', 318 | '1000g2010_ceu'=>'CEU.sites.2010_03', '1000g2010_yri'=>'YRI.sites.2010_03', '1000g2010_jptchb'=>'JPTCHB.sites.2010_03', 319 | '1000g2010jul_ceu'=>'CEU.sites.2010_07', '1000g2010jul_yri'=>'YRI.sites.2010_07', '1000g2010jul_jptchb'=>'JPTCHB.sites.2010_07', 320 | '1000g2010nov_all'=>'ALL.sites.2010_11', '1000g2011may_all'=>'ALL.sites.2011_05' 321 | ); #for backward compatibility 322 | for my $i (0 .. @protocol-1) { 323 | my $dbtype1; 324 | if ($operation[$i] eq 'g') { 325 | $dbtype1 = $dbtype1{$genetype} || $genetype; 326 | } elsif ($operation[$i] eq 'm') { 327 | next; 328 | } else { 329 | $dbtype1 = $dbtype1{$protocol[$i]} || $protocol[$i]; 330 | } 331 | 332 | if ($protocol[$i] =~ m/^1000g(20\d\d)([a-z]{3})_([a-z]+)$/) { 333 | my %monthhash = ('jan'=>'01', 'feb'=>'02', 'mar'=>'03', 'apr'=>'04', 'may'=>'05', 'jun'=>'06', 'jul'=>'07', 'aug'=>'08', 'sep'=>'09', 'oct'=>'10', 'nov'=>'11', 'dec'=>'12'); 334 | $dbtype1 = uc ($3) . '.sites.' . $1 . '_' . $monthhash{$2}; 335 | } 336 | my $file; 337 | if ($dbtype1 ne 'generic') { 338 | $file = $buildver . "_" . $dbtype1 . ".txt"; 339 | push @file, $file; 340 | } 341 | } 342 | 343 | for my $i (0 .. @file-1) { 344 | my $dbfile = File::Spec->catfile ($dbloc, $file[$i]); 345 | -f $dbfile or die "Error: the required database file $dbfile does not exist. Please download it via -downdb argument by annotate_variation.pl.\n"; 346 | } 347 | } 348 | 349 | 350 | =head1 SYNOPSIS 351 | 352 | variants_reduction.pl [arguments] 353 | 354 | Optional arguments: 355 | -h, --help print help message 356 | -m, --man print complete documentation 357 | -v, --verbose use verbose output 358 | --protocol comma-delimited string specifying annotation protocol 359 | --operation comma-delimited string specifying type of operation 360 | --outfile output file name prefix 361 | --buildver genome build version (default: hg18) 362 | --remove remove all temporary files 363 | --genetype gene definition (default: refgene) 364 | --aaf_threshold alternative allele frequency threshold for filtering 365 | --(no)checkfile check if database file exists (default: ON) 366 | --genericdbfile specify generic db file 367 | --ljb_sift_threshold specify the threshold for ljb_sift (default: 0.95) 368 | --ljb_pp2_threshold specify the threshold for ljb_pp2 (default: 0.85) 369 | --ljb2_sift_threshold specify the threshold for ljb2_sift (default: 0.05) 370 | --ljb_pp2hvar_threshold specify the threshold for ljb2_pp2hvar (default: 0.909) 371 | --ljb_pp2hdiv_threshold specify the threshold for ljb2_pp2hvar (default: 0.957) 372 | --argument commad-delimited strings as optional argument for each operation 373 | 374 | 375 | Function: automatically run a pipeline on a list of variants (potentially 376 | whole-genome SNPs from a patient with Mendelian disease) and identify a small 377 | subset that are most likely causal for Mendelian diseases 378 | 379 | Example: variants_reduction.pl sample.avinput humandb/ -protocol nonsyn_splicing,genomicSuperDups,phastConsElements46way,1000g2012apr_all,esp5400_ea,esp5400_aa,snp135NonFlagged,dominant -operation g,rr,r,f,f,f,f,m -out reduce -buildver hg19 380 | 381 | Version: $Date: 2019-10-24 00:05:28 -0400 (Thu, 24 Oct 2019) $ 382 | 383 | =head1 OPTIONS 384 | 385 | =over 8 386 | 387 | =item B<--help> 388 | 389 | print a brief usage message and detailed explanation of options. 390 | 391 | =item B<--man> 392 | 393 | print the complete manual of the program. 394 | 395 | =item B<--verbose> 396 | 397 | use verbose output. 398 | 399 | =item B<--protocol> 400 | 401 | comma-delimited string specifying annotation protocol. These strings typically 402 | represent database names in ANNOVAR. 403 | 404 | =item B<--operation> 405 | 406 | comma-delimited string specifying type of operation. These strings can be g 407 | (gene), r (region), rr (region reverse), f (filter) or fr (filter reverse). The 408 | reverse suffix is needed for scores where higher ones are functionally important 409 | ones, unlike other scores (such as allele frequency) where smaller scores are 410 | functionally important ones. For ljb_sift/ljb2_sift and ljb_pp2/ljb2_pp2, the 411 | reverse mechanism is set automatically for users to make life easier. 412 | 413 | =item B<--outfile> 414 | 415 | the prefix of output file names 416 | 417 | =item B<--buildver> 418 | 419 | specify the genome build version 420 | 421 | =item B<--remove> 422 | 423 | remove all temporary files. By default, all temporary files will be kept for 424 | user inspection, but this will easily clutter the directory. 425 | 426 | =item B<--genetype> 427 | 428 | specify the gene definition, such as refgene (default), ucsc known gene, ensembl 429 | gene and gencode gene. 430 | 431 | =item B<--aaf_threshold> 432 | 433 | specify the alternative allele frequency threshold. This argument works 434 | for 1000 Genomes Project, ESP database and CG (complete genomics) database. 435 | 436 | =item B<--(no)checkfile> 437 | 438 | the program will check if all required database files exist before execution of annotation 439 | 440 | =item B<--genericdbfile> 441 | 442 | specify the genericdb file used in -dbtype generic 443 | 444 | =item B<--ljb_sift_threshold> 445 | 446 | specify the LJB_SIFT threshold for filter operation (default: 0.95). NOTE THAT 447 | IN LJB_SIFT, THE SIFT SCORE IS REPORTED AS 1-SIFT. 448 | 449 | =item B<--ljb_pp2_threshold> 450 | 451 | specify the LJB_PP2 threshold for filter operation (default: 0.85) 452 | 453 | =item B<--ljb2_sift_threshold> 454 | 455 | specify the LJB2_SIFT threshold for filter operation (default: 0.05). NOTE THAT 456 | IN LJB2_SIFT, SIFT SCORE IS REPORTED AS THE ORIGINAL SCORE. 457 | 458 | =item B<--ljb2_pp2hdiv_threshold> 459 | 460 | specify the LJB_PP2DIV threshold for filter operation (default: 0.957) 461 | 462 | =item B<--ljb_pp2hvar_threshold> 463 | 464 | specify the LJB_PP2_HVAR threshold for filter operation (default: 0.909) 465 | 466 | =item B<--argument> 467 | 468 | comma-delimited argument list to be supplied to each of the operations. This 469 | allows users to fine-tune the reduction procedure. 470 | 471 | =back 472 | 473 | =head1 DESCRIPTION 474 | 475 | ANNOVAR is a software tool that can be used to functionally annotate a list of 476 | genetic variants, such as those generated from next-generation sequencing 477 | experiments. 478 | 479 | The variants_reduction.pl program within the ANNOVAR package 480 | provides users with the ability to perform stepwise variants reduction on a 481 | large set of input variants, to help trim down to a list of functionally 482 | important variants. Through the --protocol argument, users can specify a list of 483 | procedures to filter down variants, step by step. 484 | 485 | ANNOVAR is freely available to the community for non-commercial use. For 486 | questions or comments, please contact $Author: Kai Wang $. 487 | 488 | =cut -------------------------------------------------------------------------------- /inst/extdata/IntOGen_cancer_driver_gene.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/123xiaochen/VCFshiny/f0f451c2ea4f2733ca89eebac98e360997c60298/inst/extdata/IntOGen_cancer_driver_gene.rds -------------------------------------------------------------------------------- /inst/extdata/example_data.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/123xiaochen/VCFshiny/f0f451c2ea4f2733ca89eebac98e360997c60298/inst/extdata/example_data.rds -------------------------------------------------------------------------------- /inst/markdown/images/Fold_Format.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/123xiaochen/VCFshiny/f0f451c2ea4f2733ca89eebac98e360997c60298/inst/markdown/images/Fold_Format.png -------------------------------------------------------------------------------- /inst/markdown/images/Input File Format.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/123xiaochen/VCFshiny/f0f451c2ea4f2733ca89eebac98e360997c60298/inst/markdown/images/Input File Format.png -------------------------------------------------------------------------------- /inst/markdown/images/workflow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/123xiaochen/VCFshiny/f0f451c2ea4f2733ca89eebac98e360997c60298/inst/markdown/images/workflow.jpg -------------------------------------------------------------------------------- /inst/markdown/installation.md: -------------------------------------------------------------------------------- 1 |

Abstract

2 | 3 |

Variants produced by next-generation sequencing are often recoded in variant call format (VCF) files. The VCF file stores the details of variations, including chromosome location, base sequence, base quality, read depth, genotype, etc. However, deciphering relevant biological insights from the VCF file can be a challenging task for studies without bioinformatics and programming backgrounds. Here, we described an R/Shiny application package named VCFshiny for interpreting and visualizing the variants stored in VCF files in an interactive and user-friendly way. VCFshiny provides annotations of two kinds of software, Annovar and VariantAnnotation, while summarizing variation information, These include total variation, variation overlap between samples, base changes for single nucleotide variants, length distributions of insertions and deletions, mutation-associated genes, variation distributions in the genome, local variation in cancer driver genes and cancer signature analysis. In each analysis session, we provided multiple visualization methods to help obtain an intuitive graph for publishing and sharing.

4 | 5 | 6 | 7 |

Getting Start

8 | 9 |

Requirements

10 | (1). R (>= 4.2.0).
11 | (2). Shiny (>= 1.6.0) 12 | 13 |

How to install shiny package:

14 | 15 | ``` 16 | ## Open R ## you may need open R first: 17 | install.package("shiny") 18 | ``` 19 | 20 |

How to install VCFshiny package:

21 | 22 | ``` 23 | ## install.packages("devtools") ## you may need install devtools first 24 | devtools::install_github("123xiaochen/VCFshiny") 25 | ``` 26 |

Getting Start

27 | 28 | ``` 29 | ## Loading and run the package. 30 | library(VCFshiny) 31 | VCFshiny::startVCFshiny() 32 | ``` 33 |

Prepare Data

34 |

In this section, we will introduce how to prepare two different input data sets:

35 | 36 |

Source of VCF input data

37 |

The Variant Call Format (VCF) is used to record gene sequence variations. It is also the first file format to be understood for genome population correlation analysis. The file is divided into two main parts: the Header comment section, which begins with #, and the body section.

38 | 39 |

Source of TXT input data

40 |

TXT files are one of several output formats annotated by *Annovar* ([Wang K, Li M, Hakonarson H. 2010](references.html#ref10)), which is able to analyze genetic variations in various genomes using the latest data. Because some users cannot annotate the steps, We provide Annovar (Wang K, Li M, Hakonarson h. 2010) and VariantAnnotation (10.18129 / B9. Bioc. VariantAnnotation) two methods of annotation in the VCFshiny, Users can choose to annotate themselves or use the tool.

41 | 42 |

Input data requirements

43 | 44 |

The input file requires all data to be stored in a compressed folder in the format of the file name.

45 | 46 |

Input compress files requirements

47 | 48 | 49 | 50 | (1). The compressed file name must be the same as the name of the compressed folder.
51 | (2). The compressed file can be in *.tar. gz or *.zip format. 52 | 53 |

Input File Name Requirements

54 | 55 | 56 | 57 | (1). The first box represents the sample name, which can be the group of experiments and the number of repetitions, connected by the character "-" or "_".
58 | (2). The second box represents the data type, which can be snp or indel data. When snp and indel are not classified in the data, this box can be absent **(I)**.
59 | (3). The third box represents the data format, which can be vcf files, vcf. gz compressed files, and Annovar annotated TXT files.
60 | (4). The contents of the three boxes are connected by ".". 61 | 62 |

Documentation

63 | 64 | The documentation is available at here , the doc include a tutorial and example gallery. 65 | 66 |

Development

67 | 68 | VCFshiny development takes place on Github: https://github.com/123xiaochen/VCFshiny 69 | 70 | Please submit any reproducible bugs you encounter to the issue tracker 71 | 72 | We will also put most commonly encountered issues in the ***FAQ*** page. 73 | 74 | -------------------------------------------------------------------------------- /inst/shiny/modules/0.Introduction.R: -------------------------------------------------------------------------------- 1 | tabItem( 2 | tabName = "introduction", 3 | fluidPage( 4 | style = "margin-left:100px;margin-right:100px;", 5 | column( 6 | 12, 7 | includeMarkdown(system.file("markdown", "installation.md", package = "VCFshiny")) 8 | ) 9 | ) 10 | ) 11 | -------------------------------------------------------------------------------- /inst/shiny/modules/1.Upload_server.R: -------------------------------------------------------------------------------- 1 | # 第一部分 :数据的读入 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2 | 3 | #读取数据------------------------------- 4 | raw_variants_list <- eventReactive(input$sample_data, { 5 | withProgress(message = "processing", min = 0, max = 1, { 6 | cat(">> preparing data upload ... \t\t", format(Sys.time(), "%Y-%m-%d %X"), "\n") 7 | req(input$use_example, input$sample_data) 8 | if (input$use_example == "TRUE") { 9 | vcf_example <- readRDS(system.file("extdata", "example_data.rds", package = "VCFshiny")) 10 | return(vcf_example) 11 | }else if(input$use_example == "FALSE"){ 12 | req(input$input_file, input$sample_data) 13 | if(file.exists(stringr::str_remove(string = input$input_file$name, pattern = ".gz|.zip|.tar.gz"))){ 14 | unlink(stringr::str_remove(string = input$input_file$name, pattern = ".gz|.zip|.tar.gz"), unlink = T) 15 | } 16 | if(stringr::str_detect(input$input_file$name, pattern = "gz$")){ 17 | utils::untar(input$input_file$datapath, exdir = ".") 18 | }else if(stringr::str_detect(input$input_file$name, pattern = "zip$")){ 19 | utils::unzip(input$input_file$datapath, exdir = ".") 20 | } 21 | 22 | incProgress(0.2, detail = "uncompressing file...") 23 | input_dir <- stringr::str_remove(string = input$input_file$name, pattern = ".gz|.zip|.tar.gz") 24 | file_split_name <- strsplit(list.files(input_dir), ".", fixed = T) 25 | 26 | #读入文件 27 | if(file_split_name[[1]][length(file_split_name[[1]])] == "gz"){ 28 | file_path <- dir(input_dir, pattern = "*.gz$", full.name = T) #构建文件夹路径 29 | file_names <- dir(input_dir, pattern = "*.gz$") %>% stringr::str_remove(".vcf.gz")#构建文件名 30 | ALL_df_List <- lapply(file_path, function(x){ ALL <- as.data.frame(vcfR::read.vcfR(x,verbose = F)@fix) }) 31 | names(ALL_df_List) <- (file_names) 32 | }else if(file_split_name[[1]][length(file_split_name[[1]])] == "vcf"){ 33 | file_path <- dir(input_dir, pattern = "*.vcf$", full.name = T) #构建文件夹路径 34 | file_names <- dir(input_dir, pattern = "*.vcf$") %>% stringr::str_remove(".vcf") #构建去后缀后的文件名 35 | ALL_df_List <- lapply(file_path, function(x){ ALL <- as.data.frame(vcfR::read.vcfR(x,verbose = F)@fix) }) 36 | names(ALL_df_List) <- (file_names) 37 | }else if(file_split_name[[1]][length(file_split_name[[1]])] == "txt"){ 38 | file_path <- dir(input_dir, pattern = "*.txt$", full.name = T)#构建文件夹路径 39 | file_names <- dir(input_dir, pattern = "*.txt$") %>% stringr::str_remove(".txt")#构建去后缀后的文件名 40 | ALL_df_List <- lapply(file_path, function(x){ ; ALL <- read.table(x, header = T, sep = "\t")}) 41 | names(ALL_df_List) <- (file_names) 42 | } 43 | 44 | unlink(strsplit(input$input_file$name,".",fixed = T)[[1]][1], recursive = T) 45 | cat(">> preparing data classification ... \t\t", format(Sys.time(), "%Y-%m-%d %X"), "\n") 46 | incProgress(0.3, detail = "loading file...") 47 | 48 | #提取Ensembl-VEP注释结果 49 | if(stringr::str_detect(ALL_df_List[[1]][1,ncol(ALL_df_List[[1]])], pattern = "CSQ=")){ 50 | cl <- parallel::makeCluster(4) 51 | ALL_List <- parallel::parLapply(cl, 1:length(ALL_df_List), function(x){ 52 | Select_df <- lapply(1:nrow(ALL_df_List[[x]]), function(y){ 53 | data <- ALL_df_List[[x]]$INFO[y] %>% strsplit("\\|") %>% unlist() 54 | number <- seq(1, length(data), 38) 55 | df <- data.frame(ALL_df_List[[x]][y, 1:5], 56 | consequence = paste(na.omit(unique(data[number + 1][data[number + 1] != ""])), collapse = ';'), 57 | symbol = paste(na.omit(unique(data[number + 3][data[number + 3] != ""])), collapse = ';')) 58 | }) %>% dplyr::bind_rows() 59 | return(Select_df) 60 | }) 61 | parallel::stopCluster(cl) 62 | names(ALL_List) <- names(ALL_df_List) 63 | ALL_df_List <- ALL_List 64 | } 65 | 66 | incProgress(0.4, detail = "displaying file...") 67 | # 分割SNP、Indel 数据 68 | if("snp" %in% strsplit(names(ALL_df_List)[1], ".", fixed = T)[[1]] | 69 | "indel" %in% strsplit(names(ALL_df_List)[1], ".", fixed = T)[[1]]){ #检测是否已经分过SNP、Indel了 70 | return(ALL_df_List) 71 | }else{ 72 | snp_list <- lapply(ALL_df_List, function(x){ 73 | df <- x[nchar(x[, 4]) == nchar(x[, 5]), ] 74 | }) 75 | names(snp_list) <- paste(names(ALL_df_List), "snp", sep = ".") 76 | 77 | indel_list <- lapply(ALL_df_List, function(x){ 78 | df <- x[nchar(x[, 4]) != nchar(x[, 5]), ] 79 | }) 80 | names(indel_list) <- paste(names(ALL_df_List),"indel", sep = ".") 81 | raw_variant_list <- append(indel_list, snp_list) 82 | return(raw_variant_list) 83 | } 84 | 85 | } 86 | }) 87 | }) 88 | 89 | 90 | # raw_variants_select_list <- reactive({ 91 | # ALL_df_List <- raw_variants_list() 92 | # if("snp" %in% strsplit(names(ALL_df_List)[1], ".", fixed = T)[[1]] | 93 | # "indel" %in% strsplit(names(ALL_df_List)[1], ".", fixed = T)[[1]]){ #检测是否已经分过SNP、Indel了 94 | # return(ALL_df_List) 95 | # }else{ 96 | # snp_list <- lapply(ALL_df_List, function(x){ 97 | # df <- x[nchar(x[, 4]) == nchar(x[, 5]), ] 98 | # }) 99 | # names(snp_list) <- paste(names(ALL_df_List), "snp", sep = ".") 100 | # 101 | # indel_list <- lapply(ALL_df_List, function(x){ 102 | # df <- x[nchar(x[, 4]) != nchar(x[, 5]), ] 103 | # }) 104 | # names(indel_list) <- paste(names(ALL_df_List),"indel", sep = ".") 105 | # raw_variant_list <- append(indel_list, snp_list) 106 | # return(raw_variant_list) 107 | # } 108 | # }) 109 | 110 | #对读取数据根据group交互选择--------------------------------------------------------------------------- 111 | output$sample_id <- renderUI({ 112 | samples <- names(raw_variants_list()) 113 | selectInput("sampleID", "Select your samples to view:", choices = samples, width = "40%") 114 | }) 115 | 116 | #对读取数据根据group交互选择后并进行显示 117 | output$raw_sample <- DT::renderDataTable({ 118 | req(input$sampleID) 119 | raw_variants_list()[[input$sampleID]] 120 | }, rownames = T, options = list(scrollX = TRUE, pageLength =5)) 121 | -------------------------------------------------------------------------------- /inst/shiny/modules/1.Upload_ui.R: -------------------------------------------------------------------------------- 1 | tabItem( 2 | tabName = "datainput", 3 | fluidRow( 4 | box( 5 | title = "Data Input", width = 3, status = "info", collapsible = T, 6 | fileInput( 7 | inputId = "input_file",label = "Upload your data:", 8 | multiple = F, accept = c("gz/zip") 9 | ), 10 | prettyRadioButtons(inputId = "use_example", label = "Load example data ?", choices = c("TRUE", "FALSE"), 11 | selected = "FALSE", inline = T, animation = "tada", shape = "square", bigger = T, width = "100%"), 12 | actionButton("sample_data","Upload Data", width = "100%", style = "background-color: #76a5af; border-radius: 28px;"), 13 | ), 14 | box(title = "Data Display", width = 9, status = "primary", collapsible = T, 15 | uiOutput("sample_id"), 16 | shinycssloaders::withSpinner(DT::dataTableOutput("raw_sample")) 17 | ), 18 | column( 19 | 12, 20 | wellPanel( 21 | tags$h3("Explanation of input data and example data !"), 22 | tags$h4("Requirements for input data:"), 23 | p("Before using the tool, please read the introduction, understand the required file naming format, and make sure that the input file is the annotated variant storage file. 24 | The format of the input file can be a TXT file, a VCF file, or a VCF.gz file, and make sure that the input file is a compressed folder where all the data is stored.."), 25 | tags$li("Requirements for VCF input data:"), 26 | p("The Variant Call Format (VCF) is used to record gene sequence variations. 27 | It is also the first file format to be understood for genome population correlation analysis. 28 | The file is divided into two main parts: the Header comment section, which begins with #, and the body section. 29 | "), 30 | tags$li("Requirements for TXT input data:"), 31 | p("The txt file is one of several output formats followed by tab-delimited comments. 32 | Since some users cannot annotate steps, we provide two annotation methods, Annovar and VariantAnnotation, which users can choose to annotate themselves or use this tool."), 33 | tags$h4("The source of example data:"), 34 | p("Sample data are reported from AGBE, published in Nucleic Acids Res:A dual deaminase-mediated base editor by fusing CGBE with ABE for creating a saturated mutant population with multiple editing patterns. 35 | The author has participated in the analysis of the relevant data in the paper, so four of the five data samples are selected as example data.") 36 | ) 37 | ) 38 | ) 39 | ) 40 | -------------------------------------------------------------------------------- /inst/shiny/modules/10.mutational_signature_server.R: -------------------------------------------------------------------------------- 1 | output$signature_sample_id <- renderUI({ 2 | virtualSelectInput( 3 | inputId = "signature_sampleID", label = "Select samples:", 4 | choices = unique(gsub("\\..*","",names(raw_variants_list()))), 5 | selected = unique(gsub("\\..*","",names(raw_variants_list()))), 6 | multiple = T, search = F, width = "100%" 7 | ) 8 | }) 9 | 10 | mutational_signature_df <- eventReactive(input$analysis_signature, { 11 | raw_variants_list <- raw_variants_list() 12 | user <- lapply(input$signature_sampleID, function(x){ 13 | name <- stringr::str_subset(names(raw_variants_list), pattern = x) 14 | data <- lapply(name, function(y){ 15 | df1 <- raw_variants_list[[y]][,1:5] 16 | }) %>% bind_rows() 17 | data$sample <- x 18 | return(data) 19 | }) %>% bind_rows() 20 | 21 | if(length(unique(user$sample)) == 1){ 22 | sendSweetAlert(session = session, title = "Warning", text = "The number of samples should be greater than 1 !", type = "warning") 23 | return() 24 | } 25 | user <- user[user[,1] %in% c("chr1","chr10","chr11","chr12","chr13","chr14","chr15","chr16","chr17","chr18","chr19","chr2","chr20","chr21","chr22", 26 | "chr3","chr4","chr5","chr6","chr7","chr8","chr9","chrX","chrY" ), ] 27 | 28 | musica_data <- musicatk::create_musica(x = user, genome = musicatk::select_genome(input$signature_genome)) 29 | musicatk::build_standard_table(musica_data, g = musicatk::select_genome(input$signature_genome), table_name = input$Signature_Build_Table_Name, overwrite = T) 30 | result_data <- musicatk::discover_signatures(musica = musica_data, table_name = input$Signature_Build_Table_Name, num_signatures = input$num_signatures, 31 | algorithm = input$signature_discover_algorithm, nstart = 10) 32 | result_data 33 | return(result_data) 34 | }) 35 | 36 | # Mutational Signature Plot Display and Download 37 | #draw 38 | mutational_signature_plot <- eventReactive(input$analysis_signature, { 39 | mutational_signature_df <- mutational_signature_df() 40 | if(input$signature_compare_cosmic == "FALSE"){ 41 | musicatk::plot_signatures(mutational_signature_df, text_size = input$signature_discover_text_size, facet_size = input$signature_discover_facet_size) 42 | }else{ 43 | comapre_cosmic <- musicatk::compare_cosmic_v2(mutational_signature_df, threshold = input$signature_discover_compare_threshold, ) 44 | } 45 | }) 46 | #display 47 | output$Display_mutational_signature_plot <- renderPlot( 48 | return(mutational_signature_plot()) 49 | ) 50 | #download 51 | output$Download_mutational_signature_Plot <- downloadHandler( 52 | filename = function(){ paste0("10_mutational_signature_",input$Signature_Build_Table_Name, ".pdf")}, 53 | content = function(file){ 54 | pdf(file, width = input$Mutational_Signature_download_width, height = input$Mutational_Signature_download_height) 55 | print(mutational_signature_plot()) 56 | dev.off() 57 | } 58 | ) 59 | 60 | # Mutational Signature Data Display and Download 61 | #display 62 | output$Display_mutational_signature_data <- DT::renderDataTable( 63 | return(mutational_signature_df()@signatures), 64 | options = list( 65 | scrollX = TRUE, 66 | pageLength = 5 67 | ) 68 | ) 69 | #download 70 | output$Download_mutational_signature_data <- downloadHandler( 71 | filename = function() {paste0("10_mutational_signature_", input$Signature_Build_Table_Name, ".csv")}, 72 | content = function(file) { 73 | write.csv(mutational_signature_df()@signatures, file, row.names = T) 74 | } 75 | ) 76 | 77 | 78 | -------------------------------------------------------------------------------- /inst/shiny/modules/10.mutational_signature_ui.R: -------------------------------------------------------------------------------- 1 | tabItem( 2 | tabName = "cancer_signature", 3 | fluidRow( 4 | box( 5 | title = "Signatures Parameter Setting", width = 3, status = "info", collapsible = T, 6 | uiOutput("signature_sample_id"), 7 | selectInput(inputId = "signature_genome", label = "Select Data Genome:", choices = c("hg19", "hg38"), selected = "hg38", width = "100%"), 8 | selectInput(inputId = "Signature_Build_Table_Name", label = "Select Data Build:", 9 | choices = c("SBS (SBS96)" = "SBS96", "DBS (DBS78)" = "DBS78", "INDEL (IND83)" = "IND83"), selected = "SBS (SBS96)", width = "100%"), 10 | selectInput(inputId = "signature_discover_algorithm", label = "Select Discover Algorithm:", choices = c("nmf", "lda"), selected = "nmf", width = "100%"), 11 | numericInput(inputId = "num_signatures", label = "Numbers Signatures:", min = 1, max = 10, value = 3, step = 1, width = "100%"), 12 | conditionalPanel("input.Signature_Build_Table_Name == 'SBS96'", 13 | selectInput(inputId = "signature_compare_cosmic", label = "Compare With Cosmic?", choices = c("TRUE", "FALSE"), selected = "FALSE", width = "100%") 14 | ), 15 | actionButton(inputId = "Signature_modal_but",label = "Set Additional Parameters ...", width = "100%", 16 | style = "background-color: rgb(255,255,255);text-align:left; margin-top:15px; margin-bottom:8px", 17 | icon = icon(lib ="glyphicon" ,"glyphicon glyphicon-cog")), 18 | 19 | actionButton(inputId = "analysis_signature", label = "Analysis Signature Data", width = "100%", style = "background-color: #76a5af; border-radius: 28px;") 20 | ), 21 | bsModal( 22 | "Signature_modal", "Additional Parameters", "Signature_modal_but", size = "large", 23 | fluidRow( 24 | style = "padding: 10px", 25 | column( 26 | 12, 27 | conditionalPanel("input.signature_compare_cosmic == 'TRUE'", 28 | numericInput(inputId = "signature_discover_compare_threshold", label = "Compare With Cosmic Threshold:", min = 0.1, max = 1, value = 0.7, 29 | step = 0.05, width = "100%") 30 | ), 31 | conditionalPanel(condition = "input.signature_compare_cosmic == 'FALSE'", 32 | numericInput(inputId = "signature_discover_text_size", label = "Select Text Size:", min = 1, max = 20, value = 12, step = 1, width = "100%"), 33 | numericInput(inputId = "signature_discover_facet_size", label = "Select Facet Size:", min = 1, max = 20, value = 10, step = 1, width = "100%"), 34 | ) 35 | ) 36 | ) 37 | ), 38 | box( 39 | title = "Signatures Plot Display", width = 9, status = "primary", collapsible = T, 40 | div( 41 | style = "position: absolute; right: 0.5em; top: 0.5em;", 42 | dropdown( 43 | label = "Set Download Plot Elements", width = "100%", right = T,icon = icon(name = "glyphicon glyphicon-save",lib = "glyphicon"), 44 | sliderInput("Mutational_Signature_download_width", "Download Plot width", min = 0, max = 20, value = 8, step = 0.5, width = "100%"), 45 | sliderInput("Mutational_Signature_download_height", "Download Plot Height", min = 0, max = 15, value = 4, step = 0.5, width = "100%"), 46 | h4("Download Plot"), 47 | downloadButton("Download_mutational_signature_Plot","Download Plot") 48 | ) 49 | ), 50 | div( 51 | shinycssloaders::withSpinner(plotOutput("Display_mutational_signature_plot")) 52 | ), 53 | ), 54 | box( 55 | title = "Signatures Results Display", width = 12, status = "success", collapsible = T, 56 | div( 57 | style = "position: absolute; right:0.5em; top: 0.5em;", 58 | downloadButton('Download_mutational_signature_data','Download CSV', class = "btn", icon = icon("download", lib = "glyphicon")) 59 | ), 60 | div( 61 | shinycssloaders::withSpinner(DT::dataTableOutput("Display_mutational_signature_data")) 62 | ) 63 | ) 64 | ) 65 | ) 66 | -------------------------------------------------------------------------------- /inst/shiny/modules/11.Annotation_server.R: -------------------------------------------------------------------------------- 1 | output$Download_Annovar_Database_warning <- renderUI({ 2 | sendSweetAlert(session = session, title = "Warning", text = "If the current network environment is not good, there may be errors in the download. You can choose to re-download or download the annotation file from the Annovar official website to the Annovar/huamandb folder of the VCFshiny installation folder !", type = "warning") 3 | }) 4 | 5 | output$Annovar_Download_Name <- renderUI({ 6 | Annovar_database_table <- Annovar_database_table() 7 | selectInput(inputId = "Annovar_download_name", label = "Select Filter-based Datebase", 8 | choices = Annovar_database_table[Annovar_database_table$Version == input$Annovar_download_species & 9 | Annovar_database_table$Database_Type ==input$Annovar_download_database_type, "Name"] %>% unique(), 10 | selected = "cytoBand", width = "100%") 11 | }) 12 | 13 | output$Annovar_anno_gene_Database <- renderUI({ 14 | Annovar_database_table <- Annovar_database_table() 15 | if("-geneanno" %in% input$Annovar_anno_type){ 16 | database_name <- dir(system.file("Annovar/humandb", package = "VCFshiny"))[grep(dir(system.file("Annovar/humandb", package = "VCFshiny")), pattern = paste0(input$Annovar_species,"(.*).txt$"))] %>% 17 | stringr::str_remove(pattern = paste0("^", input$Annovar_species,"_")) %>% stringr::str_remove(pattern = ".txt$") %>% unlist() 18 | database_name1 <- database_name[database_name %in% unique(Annovar_database_table[Annovar_database_table$Version == input$Annovar_download_species & Annovar_database_table$Database_Type == "gene-based", "Name"])] 19 | 20 | if (length(database_name) == 0 | length(database_name1) == 0) { 21 | sendSweetAlert(session = session, title = "Warning", text = "Please download Region-based datebase first !", type = "warning") 22 | }else{ 23 | selectInput(inputId = "Annovar_gene_datebase", label = "Select Region-based Datebase:", choices = database_name1, width = "100%") 24 | } 25 | } 26 | }) 27 | 28 | output$Annovar_anno_region_Database <- renderUI({ 29 | Annovar_database_table <- Annovar_database_table() 30 | if("-regionanno" %in% input$Annovar_anno_type){ 31 | database_name <- dir(system.file("Annovar/humandb", package = "VCFshiny"))[grep(dir(system.file("Annovar/humandb", package = "VCFshiny")), pattern = paste0(input$Annovar_species,"(.*).txt$"))] %>% 32 | stringr::str_remove(pattern = paste0("^", input$Annovar_species,"_")) %>% stringr::str_remove(pattern = ".txt$") %>% unlist() 33 | database_name1 <- database_name[database_name %in% unique(Annovar_database_table[Annovar_database_table$Version == input$Annovar_download_species & Annovar_database_table$Database_Type == "region-based", "Name"])] 34 | 35 | if (length(database_name) == 0 | length(database_name1) == 0) { 36 | sendSweetAlert(session = session, title = "Warning", text = "Please download Region-based datebase first !", type = "warning") 37 | }else{ 38 | selectInput(inputId = "Annovar_region_datebase", label = "Select Region-based Datebase:", choices = database_name1, width = "100%") 39 | } 40 | } 41 | }) 42 | 43 | 44 | output$Annovar_anno_Filter_Database <- renderUI({ 45 | Annovar_database_table <- Annovar_database_table() 46 | if("-filter" %in% input$Annovar_anno_type){ 47 | database_name <- dir(system.file("Annovar/humandb", package = "VCFshiny"))[grepl(dir(system.file("Annovar/humandb", package = "VCFshiny")), pattern = paste0(input$Annovar_species,"(.*).txt$"))] %>% 48 | stringr::str_remove(pattern = paste0("^", input$Annovar_species,"_")) %>% stringr::str_remove(pattern = ".txt$") %>% unlist() 49 | database_name1 <- database_name[database_name %in% unique(Annovar_database_table[Annovar_database_table$Version == input$Annovar_download_species & Annovar_database_table$Database_Type == "filter-based", "Name"])] 50 | 51 | if (length(database_name) == 0 | length(database_name1) == 0) { 52 | sendSweetAlert(session = session, title = "Warning", text = "Please download Filter-based datebase first !", type = "warning") 53 | }else{ 54 | selectInput(inputId = "Annovar_filter_datebase", label = "Select Filter-based Datebase:", choices = database_name1, width = "100%") 55 | } 56 | } 57 | }) 58 | 59 | # Annovar Datebase Table --------------------------------------------------------------------------------------------------------- 60 | Annovar_database_table <- reactive({ 61 | Table <- read.csv(system.file("Annovar","Annovar_Datebase_Table.CSV", package = "VCFshiny"), header = T, sep = ",") 62 | }) 63 | 64 | 65 | output$Annovar_Database_Tab <- DT::renderDataTable({ 66 | Annovar_database_table() 67 | }, rownames = T, options = list(scrollX = TRUE, pageLength =5)) 68 | 69 | 70 | output$Annovar_Database_Tab_Download <- downloadHandler( 71 | filename = function() {paste0(input$VariantsAnno_Anno_ID,".txt")}, 72 | content = function(file) { 73 | write.table(Annovar_database_table(), file, sep = "\t", row.names = F) 74 | }) 75 | 76 | # Download Annovar annotation database------------------------------------------------------------------------------------------- 77 | download_database <- eventReactive(input$Annovar_download_section, { 78 | withProgress(message = "Downloading files ...", min = 0, max = 1, { 79 | cat(">>> preparing datebase upload ...\t\t", format(Sys.time(), "%Y-%m-%d %X"), "\n") 80 | 81 | ifelse(input$Annovar_download_name == "cytoBand", download_web <- "ucsc", download_web <- "annovar") 82 | downdb <- try(system2(command = "perl", args = paste0(system.file("Annovar", "annotate_variation.pl", package = "VCFshiny"), " -buildver ", input$Annovar_download_species, 83 | " -webfrom ", download_web, " -downdb ", input$Annovar_download_name, " ", system.file("Annovar/humandb", package = "VCFshiny")), 84 | stdout = T, stderr = T)) 85 | options(timeout=10000000000000) 86 | if (grepl("http://", downdb) %>% any()) { 87 | loop <- downdb[grepl("http://", downdb)] 88 | for (i in loop) { 89 | destfile <- stringr::str_remove(i, "http://") %>% basename() 90 | if(grepl(destfile, pattern = 'Version.txt.gz$')){ 91 | download.file(url = i, destfile = paste0(system.file("Annovar/humandb", package = "VCFshiny"), "/", input$Annovar_download_species, "_", input$Annovar_download_name ,"Version", ".txt.gz")) 92 | # down_txt <- try(download.file(url = i, destfile = paste0(system.file("Annovar/humandb", package = "VCFshiny"), "/", input$Annovar_download_species, "_", input$Annovar_download_name ,"Version", ".txt.gz"))) 93 | # if(grepl("http://", down_txt) %>% any()){ sendSweetAlert(session = session, title = "Warning", text = paste0("Please download database from: ", down_txt[grepl("http://", down_txt)]), type = "warning")} 94 | R.utils::gunzip(system.file("Annovar/humandb", paste0(input$Annovar_download_species, "_", input$Annovar_download_name,"Version" ,".txt.gz"), package = "VCFshiny"), overwrite = T) 95 | }else if (grepl(destfile, pattern = '.txt.gz$')) { 96 | download.file(url = i, destfile = paste0(system.file("Annovar/humandb", package = "VCFshiny"), "/", input$Annovar_download_species, "_", input$Annovar_download_name, ".txt.gz")) 97 | R.utils::gunzip(system.file("Annovar/humandb", paste0(input$Annovar_download_species, "_", input$Annovar_download_name, ".txt.gz"), package = "VCFshiny"), overwrite = T) 98 | }else if(grepl(destfile, pattern = '.idx.gz$')){ 99 | download.file(url = i, destfile = paste0(system.file("Annovar/humandb", package = "VCFshiny"), "/",input$Annovar_download_species, "_", input$Annovar_download_name, ".txt.idx.gz")) 100 | R.utils::gunzip(system.file("Annovar/humandb", paste0(input$Annovar_download_species, "_", input$Annovar_download_name, ".txt.idx.gz"), package = "VCFshiny"), overwrite = T) 101 | }else if(grepl(destfile, pattern = '.fa.gz$')){ 102 | download.file(url = i, destfile = paste0(system.file("Annovar/humandb", package = "VCFshiny"), "/",input$Annovar_download_species, "_", input$Annovar_download_name,"Mrna.fa.gz")) 103 | R.utils::gunzip(system.file("Annovar/humandb", paste0(input$Annovar_download_species, "_", input$Annovar_download_name,"Mrna.fa.gz"), package = "VCFshiny"), overwrite = T) 104 | } 105 | } 106 | } 107 | df <- as.data.frame(dir(system.file("Annovar/humandb", package = "VCFshiny"))) 108 | }) 109 | }) 110 | 111 | 112 | output$Annovar_Download_Tab <- DT::renderDataTable({ 113 | download_database() 114 | }, rownames = T, options = list(scrollX = TRUE, pageLength =5)) 115 | 116 | 117 | output$Annovar_Download_Tab_download <- downloadHandler( 118 | filename = function() {paste0(input$VariantsAnno_Anno_ID,".txt")}, 119 | content = function(file) { 120 | write.table(download_database(), file, sep = "\t", row.names = F) 121 | }) 122 | # annotation about Annovar ------------------------------------------------------------------------------------------------------------------- 123 | annotation_Annovar_list <- eventReactive(input$Annovar_section ,{ 124 | withProgress(message = "processing", min = 0, max = 1, { 125 | cat(">> preparing use Annovar annotation ... \t\t", format(Sys.time(), "%Y-%m-%d %X"), "\n") 126 | 127 | if(is.null(input$input_file_anno)){ 128 | sendSweetAlert(session = session, title = "Warning", text = "Please Upload data first !", type = "warning") 129 | return() 130 | } 131 | 132 | if(file.exists(stringr::str_remove(string = input$input_file_anno$name, pattern = ".gz|.zip|.tar.gz"))){ 133 | unlink(stringr::str_remove(string = input$input_file_anno$name, pattern = ".gz|.zip|.tar.gz"), recursive = T) 134 | } 135 | 136 | if(stringr::str_detect(input$input_file_anno$name, pattern = "gz$")){ 137 | utils::untar(input$input_file_anno$datapath, exdir = ".") 138 | }else if(stringr::str_detect(input$input_file_anno$name, pattern = "zip$")){ 139 | utils::unzip(input$input_file_anno$datapath, exdir = ".") 140 | } 141 | incProgress(0.2, detail = "uncompressing file...") 142 | input_dir <- stringr::str_remove(string = input$input_file_anno$name, pattern = ".gz|.zip|.tar.gz") 143 | 144 | file_split_name <- dir(input_dir, pattern = ".vcf|.vcf.gz") %>% stringr::str_remove(".vcf.gz|.vcf") 145 | input_file_name <- dir(input_dir, pattern = ".vcf|.vcf.gz", full.names = T) 146 | incProgress(0.4, detail = "annotation data...") 147 | 148 | vcf_list <- lapply(input_file_name, function(x){ 149 | name <- paste0(getwd(), "/", stringr::str_remove(string = x, pattern = ".vcf.gz|.vcf")) 150 | cat(">> preparing use Annovar convert data ... \t\t", format(Sys.time(), "%Y-%m-%d %X"), "\n") 151 | system(paste0("perl ", system.file("Annovar","convert2annovar.pl", package = "VCFshiny"), " -format vcf4 -allsample -withfreq ", x , " -out ", name)) 152 | 153 | cat(">> preparing use Annovar Gene-based annotation ... \t\t", format(Sys.time(), "%Y-%m-%d %X"), "\n") 154 | system(paste0("perl ", system.file("Annovar", "annotate_variation.pl", package = "VCFshiny"), " -geneanno -dbtype ", input$Annovar_gene_datebase, " -out ", name, 155 | " -buildver ", input$Annovar_species ," ", name, " ", system.file("Annovar/humandb", package = "VCFshiny"))) 156 | df1 <- read.table(paste0(name, ".variant_function"), header = F, sep = "\t")[,1:7] 157 | colnames(df1) <- c("Func.refGene", "Gene.refGene", "Chr","Start","End","Ref","Alt") 158 | df1 <- df1[,c(3:7,1:2)] 159 | 160 | if(("-regionanno" %in% input$Annovar_anno_type) & !("-filter" %in% input$Annovar_anno_type)){ 161 | cat(">> preparing use Annovar Region-based annotation ... \t\t", format(Sys.time(), "%Y-%m-%d %X"), "\n") 162 | system(paste0("perl ", system.file("Annovar", "annotate_variation.pl", package = "VCFshiny"), " -regionanno -dbtype ", input$Annovar_region_datebase ," -out ", name, 163 | " -buildver ", input$Annovar_species ," ", name ," ", system.file("Annovar/humandb", package = "VCFshiny"))) 164 | df2 <- read.table(paste0(name, ".",input$Annovar_species, "_cytoBand"), header = F, sep = "\t")[,2:7] 165 | colnames(df2) <- c("cytoBand", "Chr","Start","End","Ref","Alt") 166 | df <- dplyr::full_join(df1,df2, by = join_by(Chr, Start, End, Ref, Alt)) %>% na.omit() 167 | return(df) 168 | }else if(("-filter" %in% input$Annovar_anno_type) & !("-regionanno" %in% input$Annovar_anno_type)){ 169 | cat(">> preparing use Annovar Filter-based annotation ... \t\t", format(Sys.time(), "%Y-%m-%d %X"), "\n") 170 | system(paste0("perl ", system.file("Annovar", "annotate_variation.pl", package = "VCFshiny"), " -filter -dbtype ", input$Annovar_filter_datebase, 171 | " -out ", name, " -buildver ", input$Annovar_species ," ", name," ", system.file("Annovar/humandb", package = "VCFshiny"))) 172 | df3_filtered <- read.table(paste0(name, ".", input$Annovar_species, "_", input$Annovar_filter_datebase, "_filtered"), header = F, sep = "\t")[,1:5] 173 | df3_dropped <- read.table(paste0(name, ".", input$Annovar_species, "_", input$Annovar_filter_datebase, "_dropped"), header = F, sep = "\t")[,2:7] 174 | colnames(df3_dropped) <- c("datebase", "Chr","Start","End","Ref","Alt") 175 | df3_dropped <- df3_dropped %>% dplyr::mutate(datebase = as.character(datebase)) 176 | colnames(df3_filtered) <- c("Chr","Start","End","Ref","Alt") 177 | df3_filtered$datebase <- "." 178 | df3_filtered <- df3_filtered %>% dplyr::select(datebase, everything()) 179 | df3 <- rbind(df3_dropped, df3_filtered) 180 | colnames(df3)[1] <- input$Annovar_filter_datebase 181 | df <- dplyr::full_join(df1, df3, by = join_by(Chr, Start, End, Ref, Alt)) %>% na.omit() 182 | return(df) 183 | }else{ 184 | cat(">> preparing use Annovar Region-based annotation ... \t\t", format(Sys.time(), "%Y-%m-%d %X"), "\n") 185 | system(paste0("perl ", system.file("Annovar", "annotate_variation.pl", package = "VCFshiny"), " -regionanno -dbtype ", input$Annovar_region_datebase ," -out ", name, 186 | " -buildver ", input$Annovar_species ," ", name," ", system.file("Annovar/humandb", package = "VCFshiny"))) 187 | df2 <- read.table(paste0(name, ".",input$Annovar_species, "_cytoBand"), header = F, sep = "\t")[,2:7] 188 | colnames(df2) <- c("cytoBand", "Chr","Start","End","Ref","Alt") 189 | 190 | cat(">> preparing use Annovar Filter-based annotation ... \t\t", format(Sys.time(), "%Y-%m-%d %X"), "\n") 191 | system(paste0("perl ", system.file("Annovar", "annotate_variation.pl", package = "VCFshiny"), " -filter -dbtype ", input$Annovar_filter_datebase, 192 | " -out ", name, " -buildver ", input$Annovar_species ," ", name," ", system.file("Annovar/humandb", package = "VCFshiny"))) 193 | df3_filtered <- read.table(paste0(name, ".", input$Annovar_species, "_", input$Annovar_filter_datebase, "_filtered"), header = F, sep = "\t")[,1:5] 194 | df3_dropped <- read.table(paste0(name, ".", input$Annovar_species, "_", input$Annovar_filter_datebase, "_dropped"), header = F, sep = "\t")[,2:7] 195 | colnames(df3_dropped) <- c("datebase", "Chr","Start","End","Ref","Alt") 196 | colnames(df3_filtered) <- c("Chr","Start","End","Ref","Alt") 197 | df3_filtered$datebase <- "." 198 | df3_filtered <- df3_filtered %>% dplyr::select(datebase, everything()) 199 | df3 <- rbind(df3_dropped, df3_filtered) 200 | colnames(df3)[1] <- input$Annovar_filter_datebase 201 | 202 | df <- dplyr::full_join(df1,df2, by = join_by(Chr, Start, End, Ref, Alt)) %>% full_join(df3, by = join_by(Chr, Start, End, Ref, Alt)) %>% na.omit() 203 | return(df) 204 | } 205 | }) 206 | unlink(input_dir, recursive = T) 207 | names(vcf_list) <- file_split_name 208 | incProgress(0.8, detail = "Data Visualization...") 209 | return(vcf_list) 210 | }) 211 | }) 212 | 213 | # annotation about VariantAnnotation---------------------------------------------------------------------------------------------------------------------- 214 | annotation_variantsAnno_list <- eventReactive(input$VariantAnnotation_section, { 215 | withProgress(message = "processing", min = 0, max = 1, { 216 | cat(">> preparing use Annovar annotation ... \t\t", format(Sys.time(), "%Y-%m-%d %X"), "\n") 217 | 218 | if(is.null(input$input_file_Variantanno)){ 219 | sendSweetAlert(session = session, title = "Warning", text = "Please Upload data first !", type = "warning") 220 | return() 221 | } 222 | 223 | if(file.exists(stringr::str_remove(string = input$input_file_Variantanno$name, pattern = ".gz|.zip|.tar.gz"))){ 224 | unlink(stringr::str_remove(string = input$input_file_Variantanno$name, pattern = ".gz|.zip|.tar.gz"), recursive = T) 225 | } 226 | 227 | if(stringr::str_detect(input$input_file_Variantanno$name, pattern = "gz$")){ 228 | utils::untar(input$input_file_Variantanno$datapath, exdir = ".") 229 | }else if(stringr::str_detect(input$input_file_Variantanno$name, pattern = "zip$")){ 230 | utils::unzip(input$input_file_Variantanno$datapath, exdir = ".") 231 | } 232 | incProgress(0.2, detail = "uncompressing file...") 233 | input_dir <- stringr::str_remove(string = input$input_file_Variantanno$name, pattern = ".gz|.zip|.tar.gz") 234 | file_split_name <- dir(input_dir, pattern = ".vcf$|.vcf.gz$") %>% stringr::str_remove(".vcf.gz|.vcf") 235 | input_file_name <- dir(input_dir, pattern = ".vcf$|.vcf.gz$", full.names = T) %>% stringr::str_remove(".vcf.gz$|.vcf$") 236 | 237 | incProgress(0.4, detail = "annotation data...") 238 | annotation_list <- lapply(input_file_name, function(x){ 239 | name <- paste0(x, ".vcf") 240 | if(!file.exists(name)){ 241 | R.utils::gunzip(paste0(x, ".vcf.gz"), remove = T, overwrite = T) 242 | } 243 | 244 | df <- VariantAnnotation::readVcf(name, genome = input$Variantanno_species) 245 | if(!("chr1" %in% seqlevels(df))){ 246 | seqlevels(df) <- paste("chr", seqlevels(df), sep = "") 247 | } 248 | seqlevels(df, pruning.mode="coarse") <- seqlevels(df)[seqlevels(df) %in% c("chr1","chr10","chr11","chr12","chr13","chr14","chr15","chr16","chr17","chr18","chr19","chr2","chr20","chr21","chr22", 249 | "chr3","chr4","chr5","chr6","chr7","chr8","chr9","chrX","chrY" )] 250 | if(input$Variantanno_species == "hg38"){ 251 | df <- VariantAnnotation::locateVariants(MatrixGenerics::rowRanges(df), TxDb.Hsapiens.UCSC.hg38.knownGene , VariantAnnotation::AllVariants()) 252 | }else if(input$Variantanno_species == "hg19"){ 253 | df <- VariantAnnotation::locateVariants(MatrixGenerics::rowRanges(df), TxDb.Hsapiens.UCSC.hg19.knownGene , VariantAnnotation::AllVariants()) 254 | } 255 | list <- strsplit(names(GRanges(df)), split = "_|/",fixed = F) 256 | df$Ref <- sapply(list, "[",2) 257 | df$Alt <- sapply(list, "[",3) 258 | df <- as.data.frame(df, row.names = NULL) 259 | df <- df[!(is.na(df$GENEID)),] 260 | df$SYMBOLID <- AnnotationDbi::select(org.Hs.eg.db, keys = df$GENEID, keytype = "ENTREZID", columns = "SYMBOL")[,2] 261 | df <- df[, c("seqnames", "start", "end", "Ref", "Alt", "LOCATION", "SYMBOLID", "GENEID", "LOCSTART","LOCEND", "QUERYID", "TXID")] 262 | colnames(df) <- c("Chr", "Start", "End", "Ref", "Alt", "LOCATION", "SYMBOLID", "GENEID", "LOCSTART","LOCEND", "QUERYID", "TXID") 263 | df <- df %>% dplyr::group_by(Chr, Start, End, Ref, Alt, LOCATION) %>% dplyr::summarise(SYMBOLID = paste(na.omit(unique(SYMBOLID)), collapse = ";"), 264 | GENEID = paste(na.omit(unique(GENEID)), collapse = ";"), 265 | LOCSTART = paste(na.omit(unique(LOCSTART)), collapse = ";"), 266 | LOCEND = paste(na.omit(unique(LOCEND)), collapse = ";"), 267 | QUERYID = paste(na.omit(unique(QUERYID)), collapse = ";"), 268 | TXID = paste(na.omit(unique(TXID)), collapse = ";")) 269 | df <- df[df$SYMBOLID != "", ] 270 | return(df) 271 | }) 272 | unlink(input_dir, recursive = T) 273 | names(annotation_list) <- file_split_name 274 | incProgress(0.8, detail = "Data Visualization...") 275 | return(annotation_list) 276 | }) 277 | }) 278 | 279 | 280 | #Variantannotation output---------------------------------------------------------------------------------------------------------------------------- 281 | output$VariantsAnno_anno_id <- renderUI({ 282 | samples <- names(annotation_variantsAnno_list()) 283 | selectInput("VariantsAnno_Anno_ID", "Select your samples to view:", choices = samples, width = "100%") 284 | }) 285 | 286 | output$variantanno_anno_table <- DT::renderDataTable({ 287 | req(input$VariantsAnno_Anno_ID) 288 | annotation_variantsAnno_list()[[input$VariantsAnno_Anno_ID]] 289 | }, rownames = T, options = list(scrollX = TRUE, pageLength =5)) 290 | 291 | 292 | output$variantanno_tab_download <- downloadHandler( 293 | filename = function() {paste0(input$VariantsAnno_Anno_ID,".txt")}, 294 | content = function(file) { 295 | write.table(annotation_variantsAnno_list()[[input$VariantsAnno_Anno_ID]], file, sep = "\t", row.names = F) 296 | }) 297 | 298 | #Annovar output------------------------------------------------------------------------------------------------------------------------------------- 299 | output$Annovar_anno_id <- renderUI({ 300 | samples <- names(annotation_Annovar_list()) 301 | selectInput("Annovar_Anno_ID", "Select your samples to view:", choices = samples, width = "40%") 302 | }) 303 | 304 | output$Annovar_anno_table <- DT::renderDataTable({ 305 | annotation_Annovar_list()[[input$Annovar_Anno_ID]] 306 | }, rownames = T, options = list(scrollX = TRUE, pageLength =5)) 307 | 308 | 309 | output$Annovar_tab_download <- downloadHandler( 310 | filename = function() {paste0(input$Annovar_Anno_ID,".txt")}, 311 | content = function(file) { 312 | write.table(annotation_Annovar_list()[[input$Annovar_Anno_ID]], file, sep = "\t", row.names = F) 313 | }) 314 | 315 | 316 | -------------------------------------------------------------------------------- /inst/shiny/modules/11.Annotation_ui.R: -------------------------------------------------------------------------------- 1 | tabItem( 2 | tabName = "dataAnno", 3 | fluidRow( 4 | tabsetPanel( 5 | tabPanel(title = "Annovar Annotation", 6 | box(title = "Annotation Parameter Setting", width = 3, status = "info", collapsible = T, 7 | fileInput(inputId = "input_file_anno", label = "Upload Your VCF Data:", multiple = F, accept = c("gz/zip"), width = "100%"), 8 | selectInput("Annovar_species", "Select Download Species Version:", c("hg38", "hg19"), selected = "hg38", width = "100%"), 9 | selectInput(inputId = "Annovar_anno_type", label = "Select Annotation Type:", 10 | choices = c("Gene-based Annotation" = "-geneanno", "Region-based Annotation" = "-regionanno", "Filter-based Annotation" = "-filter"), 11 | selected = "Gene-based Annotation", multiple = T, width = "100%"), 12 | uiOutput("Annovar_anno_gene_Database"), 13 | uiOutput("Annovar_anno_region_Database"), 14 | uiOutput("Annovar_anno_Filter_Database"), 15 | actionButton("Annovar_section", "Annovar Annotation Data", width = "100%", 16 | style = "background-color: #76a5af; border-radius: 28px;") 17 | ), 18 | box(title = "Annotation Results Display", width = 9, status = "primary", collapsible = T, 19 | div( 20 | style = "position: absolute; right:0.5em; top: 0.5em;", 21 | downloadButton('Annovar_tab_download','Download TXT', class = "btn", icon = icon("download", lib = "glyphicon")) 22 | ), 23 | div( 24 | uiOutput("Annovar_anno_id"), 25 | shinycssloaders::withSpinner(DT::dataTableOutput("Annovar_anno_table")) 26 | ) 27 | ) 28 | ), 29 | tabPanel(title = "VariantAnnotation Annotation", 30 | box(title = "Anntation Parameter Setting", width = 3, status = "info", collapsible = T, 31 | fileInput(inputId = "input_file_Variantanno",label = "Upload Your VCF Data:", multiple = F, accept = c("gz/zip"), width = "100%"), 32 | selectInput("Variantanno_species", "organism type", c("hg38", "hg19"), selected = "hg38", width = "100%"), 33 | actionButton("VariantAnnotation_section", "VariantAnnotation Annotation Data", width = "100%", 34 | style = "background-color: #76a5af; border-radius: 28px;"), 35 | ), 36 | box(title = "Annotation Results Display", width = 9, status = "primary", collapsible = T, 37 | div( 38 | style = "position: absolute; right:0.5em; top: 0.5em;", 39 | downloadButton('variantanno_tab_download','Download TXT', class = "btn", icon = icon("download", lib = "glyphicon")) 40 | ), 41 | div( 42 | uiOutput("VariantsAnno_anno_id"), 43 | shinycssloaders::withSpinner(DT::dataTableOutput("variantanno_anno_table")) 44 | ) 45 | ) 46 | ), 47 | tabPanel(title = "Download Annovar Datebase", 48 | uiOutput("Download_Annovar_Database_warning"), 49 | box(title = "Download Parameter Setting", width = 3, status = "info", collapsible = T, 50 | selectInput("Annovar_download_species", "Select Download Species Version:", c("hg38", "hg19"), selected = "hg38", width = "100%"), 51 | selectInput("Annovar_download_database_type", "Select Download Database Type:", c("gene-based", "region-based", "filter-based"), 52 | selected = "gene-based", width = "100%"), 53 | uiOutput("Annovar_Download_Name"), 54 | actionButton("Annovar_download_section", "Download Annovar Datebase", width = "100%", 55 | style = "background-color: #76a5af; border-radius: 28px;"), 56 | ), 57 | box(title = "List of local datebase", width = 9, status = "primary", collapsible = T, 58 | div( 59 | style = "position: absolute; right:0.5em; top: 0.5em;", 60 | downloadButton('Annovar_Download_Tab_Download','Download TXT', class = "btn", icon = icon("download", lib = "glyphicon")) 61 | ), 62 | div( 63 | DT::dataTableOutput("Annovar_Download_Tab") 64 | ) 65 | ), 66 | box(title = "List of Datebase avaliable", width = 12, status = "success", collapsible = T, 67 | div( 68 | style = "position: absolute; right:0.5em; top: 0.5em;", 69 | downloadButton('Annovar_Database_Tab_Download','Download CSV', class = "btn", icon = icon("download", lib = "glyphicon")) 70 | ), 71 | div( 72 | DT::dataTableOutput("Annovar_Database_Tab") 73 | ) 74 | ) 75 | ) 76 | ) 77 | ) 78 | ) 79 | -------------------------------------------------------------------------------- /inst/shiny/modules/2.Venn_server.R: -------------------------------------------------------------------------------- 1 | #1-5、韦恩图(为做圈图取重复样本的交叉数据)--------------------------------------------------------------------------------------------------------------- 2 | 3 | #1-5.1、添加行名 4 | 5 | venn_data_list <- reactive({ 6 | raw_variants_list <- raw_variants_list() 7 | venn_data_list <- lapply(raw_variants_list,function(x){ 8 | raw_variants <- x 9 | raw_variants$name <- paste(raw_variants[, 1], raw_variants[, 2], raw_variants[, 3], raw_variants[, 4], 10 | raw_variants[, 5], sep = "_") 11 | raw_variants 12 | }) 13 | return(venn_data_list) 14 | }) 15 | 16 | 17 | #1-5.2 、根据输入筛选数据并作Venn图 18 | output$venn_group_id <- renderUI({ 19 | if(!is.null(raw_variants_list())){ 20 | group <- names(venn_data_list()) %>% stringr::str_replace_all(pattern = "-[0-9].snp|_[0-9].snp|.snp|-[0-9].indel|_[0-9].indel|.indel", replacement = "") %>% unique() 21 | virtualSelectInput("venn_group_ID","Sample groups:", choices = group, selected = group[1], multiple = F, 22 | zIndex = 4,search = F, width = "100%") 23 | } 24 | }) 25 | 26 | vennPlot_data <- eventReactive(input$venn_star, { 27 | withProgress(message = "Analyse", min = 0, max = 1, { 28 | venn_data_list <- venn_data_list() 29 | incProgress(0.4, detail = "Select Data ...") 30 | samples <- stringr::str_subset(names(venn_data_list), pattern = input$venn_group_ID, negate = F) %>% stringr::str_subset(pattern = input$venn_type_id, negate = F) 31 | venn_list <- lapply(samples, function(x){ 32 | venn_data_list[[x]][,"name"] %>% unique() 33 | }) 34 | names(venn_list) <- samples 35 | return(venn_list) 36 | }) 37 | }) 38 | 39 | vennPlot <- eventReactive(input$venn_star,{ 40 | req(input$venn_box, input$venn_ellipse, input$venn_ilcs, input$venn_sncs) 41 | venn::venn(vennPlot_data(), zcolor = "style", box = as.logical(input$venn_box), 42 | ellipse = as.logical(input$venn_ellipse),ilcs = (input$venn_ilcs), sncs = (input$venn_sncs) 43 | ) 44 | }) 45 | 46 | 47 | output$Display_venn_plot <- renderPlot({ 48 | vennPlot() 49 | }) 50 | 51 | output$Venn_download_plot <- downloadHandler( 52 | req(input$venn_type_id, input$venn_group_ID, input$VennPlot_download_width, input$VennPlot_download_height), 53 | filename = function(){ 54 | paste(paste("1",input$venn_type_id, input$venn_group_ID, "Venn_plot", sep = "_"), "pdf", sep = ".") 55 | }, 56 | content = function(file){ 57 | pdf(file, width = input$VennPlot_download_width, height = input$VennPlot_download_height) 58 | req(input$venn_box, input$venn_ellipse, input$venn_ilcs, input$venn_sncs) 59 | venn::venn(vennPlot_data(), zcolor = "style", box = as.logical(input$venn_box), 60 | ellipse = as.logical(input$venn_ellipse),ilcs = (input$venn_ilcs), sncs = (input$venn_sncs)) 61 | dev.off() 62 | } 63 | ) 64 | 65 | #1-5.3 、提取对应的交叉数据并展示 66 | venn_table <- eventReactive(input$venn_star, { 67 | samples <- stringr::str_subset(names(venn_data_list()),pattern = input$venn_group_ID, negate = F) %>% stringr::str_subset(pattern = input$venn_type_id, negate = F) 68 | venn_binded <- lapply(samples, function(x){ 69 | df <- venn_data_list()[[x]] 70 | }) %>% bind_rows() 71 | 72 | duplicated_row <- (venn_binded$name %>% table() %>% as.data.frame() %>% dplyr::filter(Freq == max(Freq)))[,1] 73 | duplicated_row <- as.character(duplicated_row) 74 | venn_binded <- venn_binded[(venn_binded$name %in% duplicated_row) , ] %>% unique() 75 | venn_binded <- subset(venn_binded, select = -c(name)) 76 | return(venn_binded) 77 | }) 78 | 79 | output$venn_Table <- DT::renderDataTable( 80 | return(venn_table()), 81 | options = list( 82 | scrollX = TRUE, 83 | pageLength = 5 84 | ) 85 | ) 86 | 87 | 88 | output$venn_tab_download <- downloadHandler( 89 | filename = function() {paste0("1_venn_tab",".csv")}, 90 | content = function(file) { 91 | write.csv(venn_table(), file, row.names = F) 92 | } 93 | ) 94 | -------------------------------------------------------------------------------- /inst/shiny/modules/2.Venn_ui.R: -------------------------------------------------------------------------------- 1 | tabItem( 2 | tabName = "venn_analyse", 3 | fluidRow( 4 | box( 5 | title = "Set Venn Plot", width = 3, status = "info", collapsible = T, 6 | prettyRadioButtons(inputId = "venn_type_id", label = "Variant type:", choices = c("snp", "indel"), 7 | inline = T, animation = "tada", shape = "square", bigger = T), 8 | uiOutput("venn_group_id"), 9 | sliderInput("venn_ilcs", "Ilcs Size:", min = 0, max = 2, value = 1, step = 0.05, width = "100%",), 10 | sliderInput("venn_sncs", "Sncs Size:", min = 0, max = 2, value = 1, step = 0.05, width = "100%",), 11 | actionButton("venn_module_but", "Additional Parameters ...", width = "100%", 12 | style = "background-color: rgb(255,255,255);text-align:left;margin-top:15px; margin-bottom:8px", 13 | icon = icon(lib ="glyphicon" ,"glyphicon glyphicon-cog")), 14 | actionButton("venn_star", "Snp / Indel Venn Plot", 15 | style = "background-color: #76a5af; border-radius: 28px;", width = "100%") 16 | ), 17 | bsModal( 18 | "vennplot_module_but", "Additional Parameters", "venn_module_but", size = "small", 19 | fluidPage( 20 | style = "padding: 10px", 21 | column( 22 | width = 12, 23 | radioGroupButtons("venn_box", "Use Box:", c("FALSE", "TRUE"),justified = T, checkIcon = list(yes = icon("ok",lib = "glyphicon")), width = "100%",), 24 | radioGroupButtons("venn_ellipse", "Use Ellipse:", choices = c("FALSE", "TRUE"),justified = T, checkIcon = list(yes = icon("ok",lib = "glyphicon")), width = "100%"), 25 | radioGroupButtons("venn_borders", "Use borders", choices = c("FALSE", "TRUE"),justified = T, checkIcon = list(yes = icon("ok",lib = "glyphicon")), width = "100%") 26 | ) 27 | ) 28 | ), 29 | box( 30 | title = "Display Venn Plot", width = 9, status = "primary", collapsible = T, 31 | div( 32 | style = "position: absolute; right: 0.5em; top: 0.5em;", 33 | dropdown( 34 | label = "Set Download Plot Elements", width = "100%", right = T, icon = icon(name = "glyphicon glyphicon-save",lib = "glyphicon"), 35 | sliderInput("VennPlot_download_width", "Download Plot width:", min = 0, max = 15, value = 6, step = 0.5, width = "100%"), 36 | sliderInput("VennPlot_download_height", "Download Plot Height:", min = 0, max = 15, value = 4, step = 0.5, width = "100%"), 37 | h4("Download Plot:"), 38 | downloadButton("Venn_download_plot","Download Plot") 39 | ) 40 | ), 41 | div( 42 | shinycssloaders::withSpinner(plotOutput("Display_venn_plot", height = "413px")) 43 | ) 44 | ), 45 | box( 46 | title = "Display Venn Data", 47 | width = 12, status = "success", collapsible = T, 48 | div( 49 | style = "position: absolute; right:0.5em; top: 0.5em;", 50 | downloadButton('venn_tab_download','Download CSV', class = "btn", icon = icon("download", lib = "glyphicon")) 51 | ), 52 | div( 53 | DT::dataTableOutput("venn_Table") 54 | ) 55 | ) 56 | ) 57 | ) 58 | -------------------------------------------------------------------------------- /inst/shiny/modules/3.summarise_barplot_server.R: -------------------------------------------------------------------------------- 1 | #1-1、SNP+Indel突变柱状图 -------------------------------------------------------------------------------------------------------------------------- 2 | 3 | #1-1.1 、 对输入数据进行数据总结并显示 4 | 5 | sumData <- eventReactive(input$summarise_plot,{ 6 | req(raw_variants_list()) 7 | summary_df <- data.frame() 8 | for(i in 1:length(raw_variants_list())){ 9 | variant_numbers = dim(raw_variants_list()[[i]])[1] 10 | samples = strsplit(names(raw_variants_list())[i], ".", fixed = T)[[1]][1] 11 | group = gsub("-[0-9]$|_[0-9]$","",samples) 12 | type = strsplit(names(raw_variants_list())[i], ".", fixed = T)[[1]][length(strsplit(names(raw_variants_list())[i], ".",fixed = T)[[1]])] 13 | summary_df <- rbind(summary_df, data.frame(group, samples, type, variant_numbers)) 14 | } 15 | return(summary_df) 16 | }) 17 | 18 | output$information <- DT::renderDataTable( 19 | return(sumData()), 20 | options = list( 21 | scrollX = TRUE, 22 | pageLength = 5 23 | ) 24 | ) 25 | 26 | output$summary_tab <- downloadHandler( 27 | filename = function() {paste0("2_summary_tab",".csv")}, 28 | content = function(file) { 29 | write.csv(sumData(), file, row.names = F) 30 | } 31 | ) 32 | 33 | #1-1.2 、 绘制SNP+Indel突变柱状图 34 | SummarisePlot <- eventReactive(input$summarise_plot,{ 35 | p <- ggpubr::ggbarplot(sumData(), x = "group",y = "variant_numbers" , facet.by = "type" , 36 | palette = "Set1", label = as.logical(input$Summariseplot_label), lab.nb.digits = 2, 37 | fill = "group" , add = "mean_sd" , width = input$bar_width , position = position_dodge(), 38 | add.params = list(width = input$error_bar_width ,size = input$error_bar_size), ggtheme = theme_classic())+ 39 | geom_jitter(size = input$jitter_size,width = input$jitter_width)+ 40 | scale_alpha_continuous(expand = expansion(mult = c(0.1, 0.1)))+ 41 | facet_wrap( ~ type, ncol = 4, scales = "free")+ 42 | xlab(NULL)+ylab("The total number of variants")+ 43 | theme(legend.position = "none", 44 | strip.background = element_blank(), 45 | strip.text = element_text(size = 21, color = "black"), 46 | axis.text.x = element_text(angle = 45, hjust = 1), 47 | axis.text = element_text(color = "black", size = input$label_text_size), 48 | axis.title = element_text(color = "black", size = input$title_text_size), 49 | text = element_text(face = "bold", family = "Times", color = "black")) 50 | 51 | if (!is.null(input$summ_ggText)) { 52 | add_funcs <- strsplit(input$summ_ggText, "\\+")[[1]] 53 | p <- p + lapply(add_funcs, function(x){ 54 | eval(parse(text = x)) 55 | }) 56 | } 57 | return(p) 58 | }) 59 | 60 | output$SummarisePlot <- renderPlot({ 61 | SummarisePlot() 62 | }) 63 | 64 | output$summarise_plot <- downloadHandler( 65 | filename = "2_Summarise_plot.pdf", 66 | content = function(file){ 67 | pdf(file,width = input$summarise_download_width,height = input$summarise_download_height) 68 | print(SummarisePlot()) 69 | dev.off() 70 | } 71 | ) 72 | -------------------------------------------------------------------------------- /inst/shiny/modules/3.summarise_barplot_ui.R: -------------------------------------------------------------------------------- 1 | tabItem( 2 | tabName = "ALL_variants", 3 | fluidRow( 4 | box( 5 | title = "Set Summary Plot",width = 3, status = "info", collapsible = T, 6 | prettyRadioButtons(inputId = "Summariseplot_label", label = "Display numbers label:", choices = c("TRUE","FALSE"), 7 | selected = "FALSE", inline = T, animation = "tada", shape = "square", bigger = T), 8 | sliderInput("title_text_size","Title text size:", min = 0, max = 30, value = 18, step = 1, width = "100%"), 9 | sliderInput("label_text_size","Label text size:", min = 0, max = 30, value = 15, step = 1, width = "100%"), 10 | sliderInput("bar_width","Bar width:", min = 0, max = 1, value = 0.8, step = 0.1, width = "100%"), 11 | actionButton("summarise_modal_but", "Additional Parameters ...", width = "100%", 12 | style = "background-color: rgb(255,255,255);text-align:left;margin-top:15px; margin-bottom:8px", 13 | icon = icon(lib ="glyphicon" ,"glyphicon glyphicon-cog")), 14 | actionButton("summarise_plot","SNP+Indel ALL Variants Plot", 15 | style = "background-color: #76a5af; border-radius: 28px;", width = "100%") 16 | ), 17 | #设置bsModal控件 18 | bsModal( 19 | "summariseplot_modal_but", "Additional Parameters", "summarise_modal_but", size = "large", 20 | fluidRow( 21 | style = "padding: 10px", 22 | column( 23 | 12, 24 | sliderInput("error_bar_width","Error bar width:", min = 0, max = 1, value = 0.3, step = 0.1, width = "100%"), 25 | sliderInput("error_bar_size","Error bar size:", min = 0, max = 2, value = 0.5, step = 0.1, width = "100%"), 26 | sliderInput("jitter_size","Jitter size:", min = 0, max = 5,value = 1,step = 0.1, width = "100%"), 27 | sliderInput("jitter_width","Jitter width:", min = 0, max = 0.5,value = 0.3,step = 0.01, width = "100%"), 28 | textAreaInput("summ_ggText", "Add ggplot2 Codes:", rows = 5, width = "100%") 29 | ) 30 | ) 31 | ), 32 | box( 33 | title = "Display Snp+Indel ALL Variants Plot",width = 9, status = "primary", collapsible = T, 34 | div( 35 | style = "position: absolute; right: 0.5em; top: 0.5em;", 36 | dropdown( 37 | label = "Set Download Plot Elements", width = "100%", right = T,icon = icon(name = "glyphicon glyphicon-save",lib = "glyphicon"), 38 | sliderInput("summarise_download_width", "Download Plot width:", min = 0, max = 15, value = 6, step = 0.5, width = "100%"), 39 | sliderInput("summarise_download_height", "Download Plot Height:", min = 0, max = 15, value = 4, step = 0.5, width = "100%"), 40 | h4("Download Plot:"), 41 | downloadButton("summarise_plot","Download Plot") 42 | ) 43 | ), 44 | div( 45 | shinycssloaders::withSpinner(plotOutput("SummarisePlot", height = "447px")) 46 | ) 47 | ), 48 | 49 | box( 50 | title = "Display Snp+Indel ALL Variants Data", width = 12, status = "success", collapsible = T, 51 | div( 52 | style = "position: absolute; right:0.5em; top: 0.5em;", 53 | downloadButton('summary_tab','Download CSV', class = "btn", icon = icon("download", lib = "glyphicon")) 54 | ), 55 | div( 56 | DT::dataTableOutput("information") 57 | ) 58 | ) 59 | ) 60 | ) 61 | -------------------------------------------------------------------------------- /inst/shiny/modules/4.SNP_Analysis_server.R: -------------------------------------------------------------------------------- 1 | #1-2、SNP 突变分析 ------------------------------------------------------------------------------------------------------------------------- 2 | #1-2-1 SNP 热图分析 ------------------------------ 3 | #1-2-11.1、构建突变热图作图表格并构建下载控件 4 | 5 | #SNP数据筛选 6 | SNP_data <- reactive({ 7 | snp_list <- lapply(stringr::str_subset(names(raw_variants_list()), pattern = ".snp"),function(x){ 8 | SNP_ALL <- raw_variants_list()[[x]] 9 | }) 10 | names(snp_list) <- stringr::str_subset(names(raw_variants_list()),pattern = ".snp") 11 | return(snp_list) 12 | }) 13 | 14 | #构建选择分组控件 15 | output$snp_analyse_group <- renderUI({ 16 | observe(SNP_data()) 17 | virtualSelectInput( 18 | inputId = "SNP_Analysis_Group", label = "Sample groups:", 19 | choices = unique(gsub("-[0-9].snp$|_[0-9].snp$|.snp","",names(SNP_data()))), 20 | selected = unique(gsub("-[0-9].snp$|_[0-9].snp$|.snp","",names(SNP_data()))), 21 | multiple = T, search = F, width = "100%" 22 | ) 23 | }) 24 | 25 | # 构建 SNP 柱状图数据 26 | SNP_Analysis_data <- eventReactive(input$SNP_Analysis_action, { 27 | req(input$SNP_Analyse_mode, input$SNP_Analysis_Group) 28 | 29 | #构建 SNP 热图数据 30 | SNP_data <- SNP_data() 31 | SNP_heatmap_data <- data.frame() 32 | for(x in 1:length(SNP_data)){ 33 | seq = c("A","T","C","G") 34 | for(y in seq){ 35 | for(z in seq){ 36 | SNP_numbers <- sum(SNP_data[[x]][, 4] == y & SNP_data[[x]][, 5] == z) 37 | REF <- y 38 | ALT <- z 39 | samples <- strsplit(names(SNP_data)[x], ".",fixed = T)[[1]][1] 40 | group <- gsub("-[0-9]$|_[0-9]$","", samples) 41 | freq <- SNP_numbers / dim(SNP_data[[x]])[1] 42 | SNP_heatmap_data <- rbind(SNP_heatmap_data, data.frame(group, samples, REF, ALT, SNP_numbers, freq)) 43 | } 44 | } 45 | } 46 | 47 | if(input$SNP_Analyse_mode == "heatmap"){ 48 | SNP_Data <- SNP_heatmap_data[SNP_heatmap_data$group %in% input$SNP_Analysis_Group, ] 49 | }else{ 50 | SNP_type_data <- SNP_heatmap_data[SNP_heatmap_data$group %in% input$SNP_Analysis_Group, ] 51 | SNP_type_data <- SNP_type_data[SNP_type_data$REF != SNP_type_data$ALT, ] 52 | SNP_type_data[(SNP_type_data$REF == "A" & SNP_type_data$ALT == "C") | (SNP_type_data$REF == "T" & SNP_type_data$ALT == "G"), "type"] <- "A>C/T>G" 53 | SNP_type_data[(SNP_type_data$REF == "A" & SNP_type_data$ALT == "G") | (SNP_type_data$REF == "T" & SNP_type_data$ALT == "C"), "type"] <- "A>G/T>C" 54 | SNP_type_data[(SNP_type_data$REF == "A" & SNP_type_data$ALT == "T") | (SNP_type_data$REF == "T" & SNP_type_data$ALT == "A"), "type"] <- "A>T/T>A" 55 | SNP_type_data[(SNP_type_data$REF == "C" & SNP_type_data$ALT == "A") | (SNP_type_data$REF == "G" & SNP_type_data$ALT == "T"), "type"] <- "C>A/G>T" 56 | SNP_type_data[(SNP_type_data$REF == "C" & SNP_type_data$ALT == "G") | (SNP_type_data$REF == "G" & SNP_type_data$ALT == "C"), "type"] <- "C>G/G>C" 57 | SNP_type_data[(SNP_type_data$REF == "C" & SNP_type_data$ALT == "T") | (SNP_type_data$REF == "G" & SNP_type_data$ALT == "A"), "type"] <- "C>T/G>A" 58 | SNP_Data <- SNP_type_data %>% group_by(type, group, samples) %>% summarise_if(is.numeric, sum) %>% as.data.frame() 59 | } 60 | return(SNP_Data) 61 | }) 62 | 63 | ##1-2-2 、绘制热图以及柱状图 64 | SNP_Analysis_plot <- eventReactive(input$SNP_Analysis_action, { 65 | if(input$SNP_Analyse_mode == "heatmap"){ 66 | data <- SNP_Analysis_data() 67 | SNP_data <- data %>% group_by(group, REF, ALT) %>% summarise_if(is.numeric, mean) %>% as.data.frame() 68 | SNP_data$freq <- SNP_data$freq * 100 69 | 70 | p <- ggplot2::ggplot(SNP_data, aes(ALT,REF,fill = freq))+ 71 | geom_tile()+ 72 | geom_text(aes(label = round(freq, digits = 2)), size = (input$heatmap_text.size)/4)+ 73 | facet_wrap(~group,ncol = input$heatmap_ncol)+ 74 | scale_fill_gradient(low = stringr::str_split(input$heatmap_color, ",")[[1]][1], 75 | high = stringr::str_split(input$heatmap_color, ",")[[1]][2])+ 76 | theme_test()+ 77 | theme(text = element_text(face = "bold", family = "Times", size = input$heatmap_text.size, color = "black")) 78 | }else{ 79 | SNP_type_data <- SNP_Analysis_data() 80 | if (input$SNP_barplot_mode == "dodge"){ 81 | p <- ggpubr::ggbarplot(SNP_type_data, x = "type", y = "freq", fill = "group", palette = "Set1", label = F, 82 | add = c("mean_sd"), width = input$SNV_barplot_bar_width, position = position_dodge(), 83 | add.params = list(width = input$SNV_barplot_err_bar_width, size = input$SNV_barplot_err_bar_size), 84 | ggtheme = theme_classic())+ 85 | xlab(NULL) + ylab("Frequency of indicated SNVs")+ 86 | theme(legend.position = "right", 87 | legend.title = element_text(color = "black", size = input$SNV_label_Text_size), 88 | legend.text = element_text(color = "black", size = input$SNV_label_Text_size), 89 | axis.text.x = element_text(angle = 45, hjust = 1), 90 | axis.text = element_text(color = "black", size = input$SNV_label_Text_size), 91 | axis.title = element_text(color = "black", size = input$SNV_title_Text_size), 92 | text = element_text(face = "bold", family = "Times", color = "black")) 93 | }else{ 94 | p <- ggplot2::ggplot(SNP_type_data, aes(x = group, y = freq, fill = type))+ 95 | geom_bar(stat = "summary", color = NA, position = "stack")+ 96 | scale_fill_brewer(palette = "Paired")+ 97 | xlab(NULL) + ylab("Frequency of indicated SNVs")+ 98 | theme_classic()+ 99 | theme(legend.position = "right", 100 | legend.title = element_text(color = "black", size = input$SNV_label_Text_size), 101 | legend.text = element_text(color = "black", size = input$SNV_label_Text_size), 102 | axis.text.x = element_text(angle = 45, hjust = 1), 103 | axis.text = element_text(color = "black", size = input$SNV_label_Text_size), 104 | axis.title = element_text(color = "black", size = input$SNV_title_Text_size), 105 | text = element_text(face = "bold", family = "Times", color = "black")) 106 | } 107 | 108 | if(!is.null(input$barplot_ggText)){ 109 | add_funcs <- strsplit(input$barplot_ggText, "\\+")[[1]] 110 | p <- p + lapply(add_funcs, function(x){ 111 | eval(parse(text = x)) 112 | }) 113 | } 114 | } 115 | return(p) 116 | }) 117 | 118 | 119 | ## 构建图片显示以及下载输出控件 120 | output$Display_SNP_Plot <- renderPlot({ 121 | return(SNP_Analysis_plot()) 122 | }) 123 | 124 | 125 | 126 | output$SNP_plot <- downloadHandler( 127 | filename = function(){ paste(paste("3_SNP_Analyse",input$SNP_Analyse_mode, sep = "_"), ".pdf")}, 128 | content = function(file){ 129 | pdf(file, width = input$SNP_download_width, height = input$SNP_download_height) 130 | print(SNP_Analysis_plot()) 131 | dev.off() 132 | } 133 | ) 134 | 135 | 136 | # 137 | # # 构建热图,柱状图输出表格 138 | output$snp_analysis_data <- DT::renderDataTable( 139 | return(SNP_Analysis_data()), 140 | options = list( 141 | scrollX = TRUE, 142 | pageLength = 5 143 | )) 144 | 145 | output$snp_tab <- downloadHandler( 146 | filename = function() {paste0("3_snp_tab",".csv")}, 147 | content = function(file) { 148 | write.csv(SNP_Analysis_data(), file, row.names = F) 149 | } 150 | ) 151 | 152 | 153 | 154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /inst/shiny/modules/4.SNP_Analysis_ui.R: -------------------------------------------------------------------------------- 1 | tabItem( 2 | tabName = "snp_analysis", 3 | fluidRow( 4 | box( 5 | title = "Set SNP Analysis Plot",width = 3, status = "info", collapsible = T, 6 | virtualSelectInput("SNP_Analyse_mode", "Analyse Mode:", choices = c("heatmap", "barplot"), multiple = F, 7 | zIndex = 4, search = F, width = "100%"), 8 | uiOutput("snp_analyse_group"), 9 | conditionalPanel( 10 | "input.SNP_Analyse_mode == 'heatmap'", 11 | textInput("heatmap_color", "Snp Heatmap High Freq Color:", value = "white,#3d85c6", width = "100%"), 12 | sliderInput("heatmap_text.size","Text size:", min = 0, max = 30, value = 18, step = 1, width = "100%"), 13 | sliderInput("heatmap_ncol", "Snp heatmap cols:", min = 1, max = 6, value = 2, width = "100%") 14 | ), 15 | conditionalPanel( 16 | "input.SNP_Analyse_mode == 'barplot'", 17 | virtualSelectInput("SNP_barplot_mode", "Barplot Position:", choices = c("dodge", "fill"), multiple = F, 18 | zIndex = 4, search = F, width = "100%"), 19 | sliderInput("SNV_title_Text_size", "Title text size:", min = 0, max = 30, value = 18, step = 1, width = "100%"), 20 | sliderInput("SNV_label_Text_size", "Label text size:", min = 0, max = 30, value = 15, step = 1, width = "100%"), 21 | ), 22 | actionButton("snp_modal_but", "Additional Parameters ...", width = "100%", 23 | style = "background-color: rgb(255,255,255);text-align:left; margin-top:15px; margin-bottom:8px", 24 | icon = icon(lib ="glyphicon" ,"glyphicon glyphicon-cog")), 25 | actionButton("SNP_Analysis_action", "SNP Analysis Plot", width = "100%", 26 | style = "background-color: #76a5af; border-radius: 28px;"), 27 | ), 28 | bsModal( 29 | "snp_modal", "Additional Parameters", "snp_modal_but", size = "large", 30 | fluidRow( 31 | style = "padding: 10px", 32 | column( 33 | 12, 34 | conditionalPanel( 35 | "input.SNP_Analyse_mode == 'heatmap'", 36 | textAreaInput("snp_heatmap_ggText", "ggplot2 codes:", rows = 5, width = "100%") 37 | 38 | ), 39 | conditionalPanel( 40 | "input.SNP_Analyse_mode == 'barplot'", 41 | sliderInput("SNV_barplot_bar_width","Bar width:", min = 0, max = 1, value = 0.8, step = 0.1, width = "100%"), 42 | sliderInput("SNV_barplot_err_bar_width","Error bar width:", min = 0, max = 1, value = 0.6, step = 0.1, width = "100%"), 43 | sliderInput("SNV_barplot_err_bar_size","Error bar size:", min = 0, max = 1, value = 0.5, step = 0.1, width = "100%"), 44 | textAreaInput("snp_barplot_ggText", "ggplot2 codes:", rows = 5, width = "100%") 45 | ) 46 | ) 47 | ) 48 | ), 49 | box( 50 | title = "Display SNP Analysis Plot", width = 9, status = "primary", collapsible = T, 51 | div( 52 | style = "position: absolute; right: 0.5em; top: 0.5em;", 53 | dropdown( 54 | label = "Set Download Plot Elements", width = "100%", right = T,icon = icon(name = "glyphicon glyphicon-save",lib = "glyphicon"), 55 | sliderInput("SNP_download_width", "Download Plot width", min = 0, max = 15, value = 6, step = 0.5, width = "100%"), 56 | sliderInput("SNP_download_height", "Download Plot Height", min = 0, max = 15, value = 4, step = 0.5, width = "100%"), 57 | h4("Download Plot"), 58 | downloadButton("SNP_plot","Download Plot") 59 | ) 60 | ), 61 | div( 62 | shinycssloaders::withSpinner(plotOutput("Display_SNP_Plot", height = "481px")) 63 | ) 64 | ), 65 | box( 66 | title = "Display SNP Analysis Data", width = 12, status = "success", collapsible = T, 67 | div( 68 | style = "position: absolute; right:0.5em; top: 0.5em;", 69 | downloadButton('snp_tab','Download CSV', class = "btn", icon = icon("download", lib = "glyphicon")) 70 | ), 71 | div( 72 | DT::dataTableOutput("snp_analysis_data") 73 | ) 74 | ) 75 | ) 76 | ) 77 | -------------------------------------------------------------------------------- /inst/shiny/modules/5.Indel_Analysis_server.R: -------------------------------------------------------------------------------- 1 | # 1-4、Indel 各个变异类型统计图 ------------------------------------------------------------------------------------------------------------------------- 2 | 3 | #Indel数据筛选 4 | Indel_data <- reactive({ 5 | Indel_ALL_list <- lapply(stringr::str_subset(names(raw_variants_list()),pattern = ".indel"),function(x){ 6 | Indel_ALL <- raw_variants_list()[[x]] 7 | }) 8 | names(Indel_ALL_list) <- stringr::str_subset(names(raw_variants_list()),pattern = ".indel") 9 | return(Indel_ALL_list) 10 | }) 11 | 12 | ### Indel 突变长度密度分布图 13 | output$Indel_analysis_group <- renderUI({ 14 | observe(Indel_data()) 15 | virtualSelectInput( 16 | inputId = "Indel_analysis_Group", label = "Sample groups:", 17 | choices = unique(gsub("-[0-9].indel$|_[0-9].indel$|.indel","",names(Indel_data()))), 18 | selected = unique(gsub("-[0-9].indel$|_[0-9].indel$|.indel","",names(Indel_data()))), 19 | multiple = T, search = F, width = "100%" 20 | ) 21 | }) 22 | 23 | Indel_Length_Data <- eventReactive(input$Indel_Analysis_action, { 24 | withProgress(message = "Loading Indel data...", min = 0, max = 1, { 25 | indel_list <- Indel_data() 26 | df <- lapply(names(indel_list), function(x){ 27 | df <- indel_list[[x]] 28 | df$Indel_length <- nchar(df[, 5]) - nchar(df[, 4]) 29 | df$Indel_type <- ifelse(df$Indel_length > 0, "Insertion", "Delection") 30 | 31 | df$group <- gsub("-[0-9].indel$|_[0-9].indel$|.indel","", x) 32 | df$samples <- x 33 | df 34 | }) %>% dplyr::bind_rows() 35 | incProgress(0.4, message = "Analyse Indel data ...") 36 | 37 | if(input$Indel_Analyse_mode == "density"){ 38 | df$Indel_length <- abs(df$Indel_length) 39 | }else { 40 | df$Indel_size = ifelse(df$Indel_length>50, "I >50bp", 41 | ifelse(df$Indel_length>25, "I 26-50bp", 42 | ifelse(df$Indel_length>10, "I 11-25bp", 43 | ifelse(df$Indel_length>7, "I 8-10bp", 44 | ifelse(df$Indel_length>4, "I 5-7bp", 45 | ifelse(df$Indel_length>1, "I 2-4bp", 46 | ifelse(df$Indel_length == 1, "I 1bp", 47 | ifelse(df$Indel_length == -1, "D 1bp", 48 | ifelse(df$Indel_length>-5, "D 2-4bp", 49 | ifelse(df$Indel_length>-8,"D 5-7bp", 50 | ifelse(df$Indel_length>-11,"D 8-10bp", 51 | ifelse(df$Indel_length>-26,"D 11-25bp", 52 | ifelse(df$Indel_length>-50,"D 26-50bp","D >50bp"))))))))))))) 53 | df$Indel_size <- factor(df$Indel_size, levels = c("D >50bp","D 26-50bp","D 11-25bp","D 8-10bp","D 5-7bp","D 2-4bp","D 1bp", 54 | "I >50bp","I 26-50bp","I 11-25bp","I 8-10bp","I 5-7bp","I 2-4bp","I 1bp")) 55 | df <- df %>% dplyr::group_by(samples, group, Indel_size) %>% dplyr::count() %>% as.data.frame() 56 | df <- lapply(df$samples, function(x){ 57 | df <- df[df$samples == x, ] 58 | df$Proportion <- ((df$n) / sum(df$n)) * 100 59 | df 60 | }) %>% bind_rows() 61 | } 62 | df <- df[df$group %in% input$Indel_analysis_Group, ] 63 | incProgress(0.8, message = "Drawwing Indel Plot ...") 64 | }) 65 | return(df) 66 | }) 67 | 68 | Indel_Length_plot <- eventReactive(input$Indel_Analysis_action, { 69 | req(Indel_Length_Data(), input$Indel_Analyse_mode) 70 | if(input$Indel_Analyse_mode == "density"){ 71 | ggplot(Indel_Length_Data(), aes(Indel_length, fill = samples, color = samples))+ 72 | xlab("Indel Length (bp)")+ 73 | geom_density(alpha = input$Indel_density_alpha, position = input$Indel_density_position)+ 74 | facet_wrap(.~Indel_type)+ 75 | geom_rug()+ 76 | theme_bw()+ 77 | theme(text = element_text(face = "bold", family = "Times", size = input$Indel_density_text_size, color = "black")) 78 | }else{ 79 | ggplot2::ggplot(Indel_Length_Data(), aes(samples, Indel_size,fill = Proportion))+ 80 | geom_tile()+ 81 | labs(x = NULL, y = NULL)+ 82 | geom_text(aes(label = round(Proportion, digits = input$Indel_heatmap_digits)), size = (input$Indel_heatmap_Text_size)/4)+ 83 | scale_fill_gradient(low = stringr::str_split(input$Indel_heatmap_color, ",")[[1]][1], 84 | high = stringr::str_split(input$Indel_heatmap_color, ",")[[1]][2])+ 85 | theme_test()+ 86 | theme(axis.text.x = element_text(angle = 45, hjust = 1), 87 | text = element_text(face = "bold", family = "Times", size = input$Indel_heatmap_Text_size, color = "black")) 88 | } 89 | }) 90 | 91 | output$Indel_Density_data <- DT::renderDataTable( 92 | return(Indel_Length_Data()), 93 | options = list( 94 | dom = 'Bfrtip', 95 | scrollX = TRUE, 96 | pageLength = 5 97 | )) 98 | 99 | output$indel_tab <- downloadHandler( 100 | filename = function() {paste0("4_indel_tab",".csv")}, 101 | content = function(file) { 102 | write.csv(Indel_Length_Data(), file, row.names = F) 103 | } 104 | ) 105 | 106 | output$Display_Indel_plot <- renderPlot({ 107 | return(Indel_Length_plot()) 108 | }) 109 | 110 | #下载图片控件 111 | output$Indel_plot <- downloadHandler( 112 | filename = function() {paste(paste("4_Indel_Analyse", input$Indel_Analyse_mode, sep = "_"),".pdf")}, 113 | content = function(file){ 114 | pdf(file, width = input$Indel_download_width, height = input$Indel_download_height) 115 | print(Indel_Length_plot()) 116 | dev.off() 117 | }) 118 | -------------------------------------------------------------------------------- /inst/shiny/modules/5.Indel_Analysis_ui.R: -------------------------------------------------------------------------------- 1 | tabItem( 2 | tabName = "Indel_analysis", 3 | fluidRow( 4 | box( 5 | title = "Set Indel Analysis Plot", width = 3, status = "info", collapsible = T, 6 | virtualSelectInput("Indel_Analyse_mode", "Analyse Mode:", choices = c("density", "heatmap"), multiple = F, 7 | zIndex = 4, search = F, width = "100%"), 8 | uiOutput("Indel_analysis_group"), 9 | conditionalPanel( 10 | "input.Indel_Analyse_mode == 'density'", 11 | virtualSelectInput("Indel_density_position", "Density Position:", choices = c("stack","identity"), multiple = F, 12 | zIndex = 4, search = F, width = "100%"), 13 | sliderInput("Indel_density_text_size","Text Size:", min = 0, max = 30, value = 18, step = 1, width = "100%"), 14 | sliderInput("Indel_density_alpha", "Alpha Size:", min = 0 , max = 1, value = 0.5, step = 0.1, width = "100%") 15 | ), 16 | conditionalPanel( 17 | "input.Indel_Analyse_mode == 'heatmap'", 18 | textInput("Indel_heatmap_color", "Indel Heatmap High Freq Color:", value = "white,red", width = "100%"), 19 | sliderInput("Indel_heatmap_Text_size", "Text size:", min = 0, max = 30, value = 18, step = 1, width = "100%"), 20 | sliderInput("Indel_heatmap_digits", "Snp Heatmap Significant Digits:", min = 0, max = 5, value = 2, width = "100%") 21 | ), 22 | actionButton("Indel_Analysis_action","SNP ALL Variants Type Plot", 23 | style = "background-color: #76a5af; border-radius: 28px;margin-top: 14px", width = "100%") 24 | ), 25 | box( 26 | title = "Display Indel Analysis Plot", width = 9, status = "primary", collapsible = T, 27 | div( 28 | style = "position: absolute; right: 0.5em; top: 0.5em;", 29 | dropdown( 30 | label = "Set Download Plot Elements", width = "100%", right = T, icon = icon(name = "glyphicon glyphicon-save", lib = "glyphicon"), 31 | sliderInput("Indel_download_width", "Download Plot width:", min = 0, max = 15, value = 9, step = 0.5, width = "100%"), 32 | sliderInput("Indel_download_height", "Download Plot Height:", min = 0, max = 15, value = 4, step = 0.5, width = "100%"), 33 | h4("Download Plot:"), 34 | downloadButton("Indel_plot","Download Plot") 35 | ) 36 | ), 37 | div( 38 | shinycssloaders::withSpinner(plotOutput("Display_Indel_plot", height = "442px")) 39 | ) 40 | ), 41 | box( 42 | title = "Display Indel Analysis Data ", width = 12, status = "success", collapsible = T, 43 | div( 44 | style = "position: absolute; right:0.5em; top: 0.5em;", 45 | downloadButton('indel_tab','Download CSV', class = "btn", icon = icon("download", lib = "glyphicon")) 46 | ), 47 | div( 48 | DT::dataTableOutput("Indel_Density_data") 49 | ) 50 | ) 51 | ) 52 | ) 53 | -------------------------------------------------------------------------------- /inst/shiny/modules/6.circle_server.R: -------------------------------------------------------------------------------- 1 | #1-6、圈图 ----------------------------------------------------------------------------------------------------------------------------------------------- 2 | #1-5.4 、 提取所有交叉数据(圈图准备数据) 3 | output$circle_group <- renderUI({ 4 | if(input$circle_type_ID == "snp"){ 5 | observe(SNP_data()) 6 | virtualSelectInput( 7 | inputId = "Circle_Group", label = "Sample groups:", 8 | choices = unique(gsub("-[0-9].snp$|_[0-9].snp$|.snp", "", names(SNP_data()))), 9 | selected = unique(gsub("-[0-9].snp$|_[0-9].snp$|.snp", "", names(SNP_data()))), 10 | multiple = T, search = F, width = "100%" 11 | ) 12 | }else{ 13 | observe(Indel_data()) 14 | virtualSelectInput( 15 | inputId = "Circle_Group", label = "Sample groups:", 16 | choices = unique(gsub("-[0-9].indel$|_[0-9].indel$|.indel","",names(Indel_data()))), 17 | selected = unique(gsub("-[0-9].indel$|_[0-9].indel$|.indel","",names(Indel_data()))), 18 | multiple = T, search = F, width = "100%" 19 | ) 20 | } 21 | }) 22 | 23 | circle_list <- eventReactive(input$circle_star, { 24 | if(input$circle_type_ID == "snp"){ 25 | variants_list <- SNP_data() 26 | }else{ 27 | variants_list <- Indel_data() 28 | } 29 | 30 | cbind_list <- lapply(input$Circle_Group, function(x){ 31 | rbind_df <- variants_list[grepl(pattern = x, x = names(variants_list))] %>% dplyr::bind_rows() 32 | rbind_df[!rbind_df %>% duplicated.data.frame(), ] 33 | }) 34 | names(cbind_list) <- input$Circle_Group 35 | circle_vperM_list <- lapply(cbind_list, function(x){ 36 | circle_df <- x 37 | circle_vperM_df <- lapply(circle_df[, 1] %>% unique,function(y){ 38 | min_pos <- min(circle_df[circle_df[, 1] == y, 2] %>% as.numeric()) 39 | max_pos <- max(circle_df[circle_df[, 1] == y, 2] %>% as.numeric()) 40 | idx_seq <- seq(min_pos, max_pos, by = 1000000) 41 | if (idx_seq[length(idx_seq)] == max_pos & idx_seq[length(idx_seq)] == min_pos) { #判断min到max增量为1000000的最后一个数是不是同时等于min/max 42 | idx_seq <- c(idx_seq, max_pos) #单数剧补一个 43 | }else if (idx_seq[length(idx_seq)] != max_pos) { 44 | idx_seq <- c(idx_seq, max_pos) #没完全覆盖的补一个 45 | } 46 | chr_df <- circle_df[circle_df[, 1] == y, ] 47 | chr_vperM_df <- lapply(1:(length(idx_seq)-1), function(z){ #统计每百万中的突变数量 48 | vPerM <- chr_df[as.numeric(chr_df[, 2]) >= idx_seq[z] & as.numeric(chr_df[, 2]) < idx_seq[z+1], ] 49 | data.frame(Chr = y, Start = idx_seq[z], End = idx_seq[z+1], Value = dim(vPerM)[1]) 50 | }) %>% dplyr::bind_rows() 51 | chr_vperM_df <- chr_vperM_df[chr_vperM_df$Value > 0, ] 52 | }) %>% dplyr::bind_rows() 53 | 54 | circle_vperM_df$Value <- log10(circle_vperM_df$Value + 1) 55 | if(stringr::str_detect(string = circle_vperM_df[1,1], pattern = "chr", negate = T)){ 56 | circle_vperM_df[,1] <- paste0("chr",circle_vperM_df[,1]) 57 | } 58 | return(circle_vperM_df) 59 | }) 60 | return(circle_vperM_list) 61 | }) 62 | 63 | # #1-6.3 绘制圈图 64 | Circle_Plot <- eventReactive(input$circle_star,{ 65 | withProgress(message = "Loading Circle data...", min = 0, max = 1, { 66 | 67 | circle_list <- circle_list() #提取每百万reads数列表 68 | par(mar = c(2,2,2,2), lwd = 1, cex = 1.5) 69 | circlize::circos.par(track.height = input$track.height, start.degree = as.numeric(input$start.degree), 70 | track.margin = c(as.numeric(input$track.margin1),as.numeric(input$track.margin2)), gap.after = as.numeric(input$track.gap.degree)) 71 | 72 | if(input$Species == "others"){ 73 | cytoband.df = read.table(input$chrom_files$datapath, colClasses = c("character", "numeric","numeric", "character", "character"), sep = "\t") 74 | chr <- cytoband.df$chr 75 | circos.initializeWithIdeogram(cytoband.df, plotType = input$chrom_plotType) 76 | }else{ 77 | chr <- circlize:::usable_chromosomes(input$Species) 78 | circos.initializeWithIdeogram(species = input$Species, plotType = input$chrom_plotType) 79 | } 80 | 81 | incProgress(0.4, message = "Analyse Circle data ...") 82 | text(0, 0, input$circle_type_ID , cex = input$circle_center_text_size) 83 | 84 | # if (length(names(circle_list)) < 3) { 85 | # col_fun <- RColorBrewer::brewer.pal(length(names(circle_list)), "Set1")[1:length(names(circle_list))] 86 | # }else{ 87 | # col_fun <- RColorBrewer::brewer.pal(length(names(circle_list)), "Set1") 88 | # } 89 | col_fun <- RColorBrewer::brewer.pal(length(names(circle_list)), "Set1") 90 | 91 | if(input$circle_type == "points"){ 92 | for(x in 1:length(circle_list)){ 93 | circlize::circos.genomicTrack(circle_list[[x]], 94 | panel.fun = function(region, value, ...) { 95 | i = getI(...) 96 | circos.genomicPoints(region, value, pch = as.numeric(input$points.pch), cex = as.numeric(input$points.size), 97 | alpha = as.numeric(input$points.alpha) , col = col_fun[x], ...) 98 | },bg.border = "grey") 99 | } 100 | }else if(input$circle_type == "lines"){ 101 | for(x in 1:length(circle_list)){ 102 | circlize::circos.genomicTrack(circle_list[[x]], 103 | panel.fun = function(region, value, ...) { 104 | i = getI(...) 105 | circos.genomicLines(region, value, type = input$lines_type, col = col_fun[x], border = col_fun[x], area = as.logical(input$lines_area), 106 | lwd = as.numeric(input$lines_lwd), lty = as.numeric(input$lines_lty), ...) 107 | },bg.border = "grey") 108 | } 109 | }else if(input$circle_type == "heatmap"){ 110 | col.max <- lapply(circle_list, function(x){ x$Value %>% max() }) %>% unlist() %>% max() 111 | for(x in 1:length(circle_list)){ 112 | circos.genomicHeatmap(circle_list[[x]][circle_list[[x]][, 1] %in% chr, ], col = colorRamp2(c(0, col.max), c("white", col_fun[x])), connection_height = NULL) 113 | } 114 | } 115 | incProgress(0.6, message = "Drawwing Circle plot ...") 116 | legend(x = as.numeric(input$legend.x.position), y = as.numeric(input$legend.y.position), pch = 15, cex = input$circle_legend_text_size, legend = names(circle_list), col = col_fun ) 117 | }) 118 | circos.clear() 119 | }) 120 | 121 | 122 | output$cirecle_PlotOutput <- renderPlot({ 123 | Circle_Plot() 124 | }) 125 | 126 | 127 | #1-6.4下载图片 128 | output$CirclePlot_download <- downloadHandler( 129 | filename = function(){ 130 | paste(paste("5", input$circle_type_ID, input$circle_type, "Circle_plot", sep = "_"),"pdf" , sep = ".") 131 | }, 132 | content = function(file){ 133 | pdf(file,width = input$CirclePlot_download_width, height = input$CirclePlot_download_height) 134 | #重新作图下载 135 | circle_list <- circle_list() #提取每百万reads数列表 136 | 137 | par(mar = c(1,1,1,1), lwd = 1, cex = 1.5) 138 | circlize::circos.par(track.height = input$track.height, start.degree = as.numeric(input$start.degree), 139 | track.margin = c(as.numeric(input$track.margin1),as.numeric(input$track.margin2)),gap.after = as.numeric(input$track.gap.degree)) 140 | 141 | if(input$Species == "others"){ 142 | cytoband.df = read.table(input$chrom_files$datapath, colClasses = c("character", "numeric","numeric", "character", "character"), sep = "\t") 143 | chr <- cytoband.df$chr 144 | circos.initializeWithIdeogram(cytoband.df, plotType = input$chrom_plotType) 145 | }else{ 146 | # print(input$Species) 147 | chr <- circlize:::usable_chromosomes(input$Species) 148 | circos.initializeWithIdeogram(species = input$Species, plotType = input$chrom_plotType) 149 | } 150 | 151 | text(0, 0, input$circle_type_ID , cex = input$circle_center_text_size) 152 | 153 | col_fun <- RColorBrewer::brewer.pal(length(names(circle_list)), "Set1") 154 | if(input$circle_type == "points"){ 155 | for(x in 1:length(circle_list)){ 156 | circlize::circos.genomicTrack(circle_list[[x]], 157 | panel.fun = function(region, value, ...) { 158 | i = getI(...) 159 | circos.genomicPoints(region, value, pch = as.numeric(input$points.pch), cex = as.numeric(input$points.size), 160 | alpha = as.numeric(input$points.alpha) , col = col_fun[x], ...) 161 | },bg.border = "grey") 162 | } 163 | }else if(input$circle_type == "lines"){ 164 | for(x in 1:length(circle_list)){ 165 | circlize::circos.genomicTrack(circle_list[[x]], 166 | panel.fun = function(region, value, ...) { 167 | i = getI(...) 168 | circos.genomicLines(region, value, type = input$lines_type, col = col_fun[x], border = col_fun[x], area = as.logical(input$lines_area), 169 | lwd = as.numeric(input$lines_lwd), lty = as.numeric(input$lines_lty), ...) 170 | },bg.border = "grey") 171 | } 172 | }else if(input$circle_type == "heatmap"){ 173 | col.max <- lapply(circle_list, function(x){ x$Value %>% max() }) %>% unlist() %>% max() 174 | for(x in 1:length(circle_list)){ 175 | circos.genomicHeatmap(circle_list[[x]][circle_list[[x]][, 1] %in% chr, ], col = colorRamp2(c(0, col.max), c("white", col_fun[x])), connection_height = NULL) 176 | } 177 | } 178 | 179 | legend(x = as.numeric(input$legend.x.position), y = as.numeric(input$legend.y.position), pch = 15, cex = input$circle_legend_text_size, legend = names(circle_list), col = col_fun ) 180 | 181 | circos.clear() 182 | 183 | dev.off() 184 | } 185 | ) 186 | -------------------------------------------------------------------------------- /inst/shiny/modules/6.circle_ui.R: -------------------------------------------------------------------------------- 1 | tabItem( 2 | tabName = "circle", 3 | fluidRow( 4 | box( 5 | title = "Set Circle Plot", width = 3, status = "info", collapsible = T, 6 | prettyRadioButtons(inputId = "circle_type_ID", label = "Analyse Type:", choices = c("snp","indel"), inline = T, 7 | animation = "tada", shape = "square", bigger = T), 8 | uiOutput("circle_group"), 9 | virtualSelectInput("circle_type","Circle Type:", choices = c("points", "lines", "heatmap"), 10 | multiple = F, zIndex = 4,search = F, width = "100%"), 11 | sliderInput("circle_legend_text_size","Legend Text Size:",min = 0, max = 5, value = 0.8, step = 0.1, width = "100%"), 12 | sliderInput("circle_center_text_size","Center Text Size:",min = 0, max = 5, value = 1.8, step = 0.1, width = "100%"), 13 | sliderInput("track.height","Track.height:",min = 0, max = 0.3,value = 0.12, step = 0.01, width = "100%"), 14 | actionButton("circle_module_but", "Additional Parameters ...", width = "100%", 15 | style = "background-color: rgb(255,255,255);text-align:left;margin-top:15px; margin-bottom:8px", 16 | icon = icon(lib ="glyphicon" ,"glyphicon glyphicon-cog")), 17 | actionButton("circle_star","WGS Data Circle Plot", 18 | style = "background-color: #76a5af; border-radius: 28px;", width = "100%"), 19 | ), 20 | bsModal( 21 | "circleplot_module_but", "Additional Parameters", "circle_module_but", size = "small", 22 | fluidPage( 23 | style = "padding:10px", 24 | checkboxGroupButtons("chrom_plotType","Chrom plotType:", c("axis", "labels", "ideogram"), selected = c("ideogram","labels"), 25 | justified = T, checkIcon = list(yes = icon("ok",lib = "glyphicon"))), 26 | sliderInput("start.degree", "Start.degree:", min = 0, max = 180,value = 90, step = 1, width = "100%"), 27 | sliderInput("track.margin1","Track.margin 1:", min = 0, max = 0.1, value = 0.02, step = 0.01, width = "100%"), 28 | sliderInput("track.margin2","Track.margin 2:", min = 0, max = 0.1, value = 0.02, step = 0.01, width = "100%"), 29 | sliderInput("track.gap.degree","Track.gap.width:", min = 0, max = 5,value = 0.6, step = 0.1, width = "100%") 30 | ) 31 | ), 32 | box( 33 | title = "Display Circle Plot", width = 6, status = "primary", collapsible = T, 34 | div( 35 | style = "position: absolute; right: 0.5em; top: 0.5em;", 36 | dropdown( 37 | label = "Set Download Plot Element", width = "100%", right = T, icon = icon(name = "glyphicon glyphicon-save",lib = "glyphicon"), 38 | sliderInput("CirclePlot_download_width", "Download Plot width:", min = 0, max = 15, value = 10, step = 0.5), 39 | sliderInput("CirclePlot_download_height", "Download Plot Height:", min = 0, max = 15, value = 10, step = 0.5), 40 | h4("Download Plot"), 41 | downloadButton("CirclePlot_download", "Download Plot") 42 | ) 43 | ), 44 | div( 45 | shinycssloaders::withSpinner(plotOutput("cirecle_PlotOutput", height = "560px")) 46 | ) 47 | ), 48 | box( 49 | title = "Set Circle Elements Plot", width = 3, status = "info", collapsible = T, 50 | selectInput( 51 | inputId = "Species", 52 | label = "Choose your Species:", 53 | c("Human" = "hg38", 54 | "Mouse" = "mm10", 55 | "Rat" = "rn6", 56 | "Sus scrofa" ="susScr11", 57 | "Dog" = "canFam4", 58 | "others" = "others"), 59 | selected = "Human", multiple = F, width = "100%" 60 | ), 61 | conditionalPanel( 62 | "input.Species == 'others'", 63 | fileInput("chrom_files", "Input your circle chrom data:", multiple = F, width = "100%") 64 | ), 65 | sliderInput("legend.x.position", "Legend plot X position:", min = -1, max = 1,value = 0.55, step = 0.05), 66 | sliderInput("legend.y.position", "Legend plot Y position:", min = -1, max = 1,value = -0.65, step = 0.05), 67 | conditionalPanel( 68 | "input.circle_type == 'points'", 69 | sliderInput("points.size", "Points Size:", min = 0, max = 1, value = 0.3, step = 0.05), 70 | selectInput("points.pch", "Points Pch:", choices = c(0, 1:25), selected = 16), 71 | sliderInput("points.alpha", "Points Alpha:", min = 0, max = 1, value = 0.5, step = 0.05) 72 | ), 73 | conditionalPanel( 74 | "input.circle_type == 'lines'", 75 | radioGroupButtons("lines_area", "Lines_Area", choices = c("TRUE", "FALSE") 76 | ,justified = T, checkIcon = list(yes = icon("ok",lib = "glyphicon"))), 77 | selectInput("lines_type", "Lines_Type:", choices = c("l", "o", "h", "s")), 78 | selectInput("lines_lty", "Lines_Lty:", choices = c(1:6), selected = 1), 79 | sliderInput("lines_lwd", "Lines_Lwd:", min = 0, max = 5, value = 2, step = 0.1) 80 | ) 81 | ) 82 | ) 83 | ) 84 | -------------------------------------------------------------------------------- /inst/shiny/modules/7.Distribution_server.R: -------------------------------------------------------------------------------- 1 | 2 | output$distribution_type_group <- renderUI({ 3 | virtualSelectInput( 4 | inputId = "distribution_type_group", label = "Sample groups:", 5 | choices = unique(gsub("-[0-9].snp|_[0-9].snp|.snp|-[0-9].indel|_[0-9].indel|.indel","",names(raw_variants_list()))), 6 | selected = unique(gsub("-[0-9].snp|_[0-9].snp|.snp|-[0-9].indel|_[0-9].indel|.indel","",names(raw_variants_list()))), 7 | multiple = T, search = F, width = "100%" 8 | ) 9 | }) 10 | 11 | output$distribution_feature_column <- renderUI({ 12 | virtualSelectInput( 13 | inputId = "distribution_feature_column", label = "Select Genomic Feature Column:", 14 | choices = colnames(raw_variants_list()[[1]]), 15 | selected = colnames(raw_variants_list()[[1]])[6], multiple = F, search = F, width = "100%" 16 | ) 17 | }) 18 | 19 | 20 | #2-1.1 构建位置分布数据 21 | distribution_binded <- eventReactive(input$plot_distribution, { 22 | distribution_bind <- data.frame() 23 | sample_ID <- stringr::str_subset(names(raw_variants_list()), pattern = input$distribution_type_id, negate = F) 24 | sample_ID <- lapply(input$distribution_type_group, function(x){ 25 | stringr::str_subset(sample_ID, pattern = x, negate = F) 26 | }) %>% unlist 27 | 28 | distribution_bind <- lapply(sample_ID, function(x){ 29 | data <- raw_variants_list()[[x]] 30 | colnames(data)[colnames(data) == input$distribution_feature_column] <- "feature_column" 31 | 32 | no_splite_df <- as.data.frame(data[grep(";|&", data$feature_column, invert = T), ]) 33 | need_splite_df <- as.data.frame(data[grep(";|&", data$feature_column), ]) 34 | if(nrow(need_splite_df)>0){ 35 | splited_df <- need_splite_df %>% tidyr::separate_rows(feature_column, sep = ";|&") %>% unique() 36 | combined_df <- rbind(no_splite_df, splited_df) 37 | }else{ 38 | combined_df <- no_splite_df 39 | } 40 | number_df <- combined_df %>% dplyr::group_by(feature_column) %>% dplyr::count() %>% as.data.frame() 41 | number_df$sample_name <- x 42 | number_df$group <- gsub("-[0-9].snp|_[0-9].snp|.snp|-[0-9].indel|_[0-9].indel|.indel", "", x) 43 | number_df$percentage <- number_df$n / sum(number_df$n) * 100 44 | number_df[number_df$percentage < 0.5, "feature_column"] <- "Other" 45 | number_df <- number_df %>% dplyr::group_by(feature_column, sample_name, group) %>% dplyr::summarise(numbers = sum(n), 46 | percentage = sum(percentage)) 47 | return(number_df) 48 | }) %>% dplyr::bind_rows() 49 | 50 | return(distribution_bind) 51 | }) 52 | 53 | output$distribution_data <- DT::renderDataTable( 54 | return(distribution_binded()), 55 | options = list( 56 | scrollX = TRUE, 57 | pageLength = 5 58 | ) 59 | ) 60 | 61 | output$distribution_tab_download <- downloadHandler( 62 | filename = function() {paste0("6_distribution_tab",".csv")}, 63 | content = function(file) { 64 | write.csv(distribution_binded(), file, row.names = F) 65 | } 66 | ) 67 | 68 | #2-1.2 做位置分布柱状图 69 | distribution_plot <- eventReactive(input$plot_distribution, { 70 | distribution_binded <- distribution_binded() 71 | if(input$distribution_type_position == "dodge"){ 72 | p <- ggpubr::ggbarplot(distribution_binded, x = "feature_column", y = "percentage", palette = "Paired", 73 | add = c("mean_sd"), fill = "group", width = input$distribution_bar_width, position = position_dodge(), 74 | add.params = list(width = input$distribution_error_bar_width, shape = "group", size = input$distribution_error_bar_size), ggtheme = theme_classic())+ 75 | xlab(NULL) + ylab("Proportion of variants distribution \n in the genomic features (%)")+ 76 | theme(legend.position = "right", 77 | legend.title = element_text(color = "black", size = input$distribution_label_text_size), 78 | legend.text = element_text(color = "black", size = input$distribution_label_text_size), 79 | axis.text.x = element_text(angle = 45, hjust = 1), 80 | axis.text = element_text(color = "black", size = input$distribution_label_text_size), 81 | axis.title = element_text(color = "black", size = input$distribution_title_text_size), 82 | text = element_text(face = "bold", family = "Times", color = "black")) 83 | }else{ 84 | p <- ggplot2::ggplot(distribution_binded, aes(x = group, y = percentage, fill = feature_column))+ 85 | geom_bar(stat = "summary", color = NA, position = "stack")+ 86 | scale_fill_brewer(palette = "Paired")+ 87 | xlab(NULL) + ylab("Proportion of variants distribution \n in the genomic features (%)")+ 88 | theme_classic()+ 89 | theme(legend.position = "right", 90 | legend.title = element_text(color = "black", size = input$distribution_label_text_size), 91 | legend.text = element_text(color = "black", size = input$distribution_label_text_size), 92 | axis.text.x = element_text(angle = 45, hjust = 1), 93 | axis.text = element_text(color = "black", size = input$distribution_label_text_size), 94 | axis.title = element_text(color = "black", size = input$distribution_title_text_size), 95 | text = element_text(face = "bold", family = "Times", color = "black")) 96 | } 97 | 98 | if (!is.null(input$distribution_ggText)) { 99 | add_funcs <- strsplit(input$distribution_ggText, "\\+")[[1]] 100 | p <- p + lapply(add_funcs, function(x){ 101 | eval(parse(text = x)) 102 | }) 103 | } 104 | 105 | return(p) 106 | }) 107 | 108 | output$Distribution_Plot <- renderPlot({ 109 | distribution_plot() 110 | }) 111 | 112 | #2-1.3 下载位置分布柱状图 113 | output$Distribution_Download <- downloadHandler( 114 | filename = function(){ 115 | paste(paste("6", input$distribution_type_id, input$distribution_type_position, "ALL_Variants_Distribution_plot", sep = "_"), "pdf",sep = ".") 116 | }, 117 | content = function(file){ 118 | pdf(file,width = input$Distribution_download_width,height = input$Distribution_download_height) 119 | print(distribution_plot()) 120 | dev.off() 121 | } 122 | ) 123 | 124 | -------------------------------------------------------------------------------- /inst/shiny/modules/7.Distribution_ui.R: -------------------------------------------------------------------------------- 1 | tabItem( 2 | tabName = "distribution", 3 | fluidRow( 4 | box( 5 | title = "Set Distribution Plot", width = 3, status = "info", collapsible = T, 6 | prettyRadioButtons(inputId = "distribution_type_id", label = "Variant type:", choices = c("snp", "indel"), inline = T, 7 | animation = "tada", shape = "square", bigger = T), 8 | uiOutput("distribution_type_group"), 9 | uiOutput("distribution_feature_column"), 10 | virtualSelectInput("distribution_type_position", "Bar Position:", choices = c("dodge", "fill"), 11 | multiple = F, zIndex = 4,search = F, width = "100%"), 12 | sliderInput("distribution_title_text_size", "Title Text Size:", min = 0, max = 30, value = 13, step = 1, width = "100%"), 13 | sliderInput("distribution_label_text_size", "Label Text Size:", min = 0, max = 30, value = 12, step = 1, width = "100%"), 14 | actionButton("distribution_module_id", "Set Additional Parameters ...", width = "100%", 15 | style = "background-color: rgb(255,255,255);text-align:left;margin-top:15px; margin-bottom:8px", 16 | icon = icon(lib ="glyphicon" ,"glyphicon glyphicon-cog")), 17 | actionButton("plot_distribution", "Variants Distribution Plot", 18 | style = "background-color: #76a5af; border-radius: 28px;", width = "100%") 19 | ), 20 | bsModal( 21 | "distribution_module", "Set Basics Elements", "distribution_module_id", size = "small", 22 | fluidPage( 23 | style = "padding:10px", 24 | column( 25 | width = 12, 26 | sliderInput("distribution_bar_width", "Bar Width:", min = 0, max = 5, value = 0.8, step = 0.1, width = "100%"), 27 | sliderInput("distribution_error_bar_width", "Error Bar Width:", min = 0, max = 1, value = 0.3, step = 0.05, width = "100%"), 28 | sliderInput("distribution_error_bar_size","Error Bar Size:", min = 0, max = 2, value = 0.5, step = 0.05, width = "100%"), 29 | textAreaInput("distribution_ggText", "Add ggplot2 Codes:", rows = 5, width = "100%") 30 | ) 31 | ) 32 | ), 33 | box( 34 | title = "Display Distribution Plot", width = 9, status = "primary", collapsible = T, 35 | div( 36 | style = "position: absolute; right: 0.5em; top: 0.5em;", 37 | dropdown( 38 | label = "Set Download Plot Elements", width = "100%", right = T, icon = icon(name = "glyphicon glyphicon-save",lib = "glyphicon"), 39 | sliderInput("Distribution_download_width", "Download Plot width", min = 0, max = 15, value = 7, step = 0.5, width = "100%"), 40 | sliderInput("Distribution_download_height", "Download Plot Height", min = 0, max = 15, value = 4, step = 0.5, width = "100%"), 41 | h4("Download Plot"), 42 | downloadButton("Distribution_Download","Download Plot") 43 | ) 44 | ), 45 | div( 46 | shinycssloaders::withSpinner(plotOutput("Distribution_Plot", height = "540px")) 47 | ) 48 | ), 49 | box( 50 | title = "Display Distribution Data", width = 12, status = "success", collapsible = T, 51 | div( 52 | style = "position: absolute; right:0.5em; top: 0.5em;", 53 | downloadButton('distribution_tab_download','Download CSV', class = "btn", icon = icon("download", lib = "glyphicon")) 54 | ), 55 | div( 56 | DT::dataTableOutput("distribution_data") 57 | ) 58 | ) 59 | ) 60 | ) 61 | -------------------------------------------------------------------------------- /inst/shiny/modules/8.VariantsGene_Summarise_server.R: -------------------------------------------------------------------------------- 1 | #2-2、找出突变基因并绘制柱状图-------------------------------------------------------------------------------------------------------------------------- 2 | 3 | # 2-2.1、筛选突变基因 4 | output$Variants_sample_id <- renderUI({ 5 | virtualSelectInput( 6 | inputId = "Variants_sampleID", label = "Select samples:", 7 | choices = unique(gsub("\\..*","",names(raw_variants_list()))), 8 | selected = unique(gsub("\\..*","",names(raw_variants_list()))), 9 | multiple = F, search = F, width = "100%" 10 | ) 11 | }) 12 | 13 | output$Variants_feature_column <- renderUI({ 14 | virtualSelectInput( 15 | inputId = "variants_feature_column", label = "Select Genomic Feature Column:", 16 | choices = colnames(raw_variants_list()[[1]]), 17 | selected = colnames(raw_variants_list()[[1]])[6], multiple = F, search = F, width = "100%" 18 | ) 19 | }) 20 | 21 | output$Variants_gene_column <- renderUI({ 22 | virtualSelectInput( 23 | inputId = "variants_gene_column", label = "Select Related Gene Column:", 24 | choices = colnames(raw_variants_list()[[1]]), 25 | selected = colnames(raw_variants_list()[[1]])[7], multiple = F, search = F, width = "100%" 26 | ) 27 | }) 28 | 29 | output$Variants_bar_position_id <- renderUI({ 30 | if (input$Variants_type_id == "all") { 31 | simplifed_df1 <- raw_variants_list()[[paste0(input$Variants_sampleID, ".indel")]] %>% dplyr::bind_rows() 32 | simplifed_df2 <- raw_variants_list()[[paste0(input$Variants_sampleID, ".snp")]] %>% dplyr::bind_rows() 33 | simplifed_df <- rbind(simplifed_df1, simplifed_df2) 34 | colnames(simplifed_df)[colnames(simplifed_df) == input$variants_feature_column] <- "feature_column" 35 | }else { 36 | simplifed_df <- raw_variants_list()[[paste0(input$Variants_sampleID, ".", input$Variants_type_id)]] 37 | colnames(simplifed_df)[colnames(simplifed_df) == input$variants_feature_column] <- "feature_column" 38 | } 39 | no_splite_df <- as.data.frame(simplifed_df[grep(";|&", simplifed_df$feature_column, invert = T), ]) 40 | need_splite_df <- as.data.frame(simplifed_df[grep(";|&", simplifed_df$feature_column), ]) 41 | if(nrow(need_splite_df) > 0){ 42 | splited_df <- need_splite_df %>% tidyr::separate_rows(feature_column, sep = ";|&") %>% unique() 43 | combined_df <- rbind(splited_df, no_splite_df) 44 | }else{ 45 | combined_df <- no_splite_df 46 | } 47 | 48 | virtualSelectInput( 49 | inputId = "Variants_bar_position_ID", label = "Select Position To Analyse:", 50 | choices = unique(combined_df$feature_column), selected = unique(combined_df$feature_column), multiple = T, zIndex = 4, search = F, width = "100%" 51 | ) 52 | }) 53 | 54 | Variants_genes <- eventReactive(input$plot_Variants_genes, { 55 | raw_variants_list <- raw_variants_list() 56 | 57 | if (input$Variants_type_id == "all") { 58 | simplifed_df1 <- raw_variants_list()[[paste0(input$Variants_sampleID, ".indel")]] %>% dplyr::bind_rows() 59 | simplifed_df2 <- raw_variants_list()[[paste0(input$Variants_sampleID, ".snp")]] %>% dplyr::bind_rows() 60 | simplifed_df <- rbind(simplifed_df1, simplifed_df2) 61 | colnames(simplifed_df)[colnames(simplifed_df) == input$variants_feature_column] <- "feature_column" 62 | colnames(simplifed_df)[colnames(simplifed_df) == input$variants_gene_column] <- "gene_column" 63 | }else { 64 | simplifed_df <- raw_variants_list()[[paste0(input$Variants_sampleID, ".", input$Variants_type_id)]] %>% dplyr::bind_rows() 65 | colnames(simplifed_df)[colnames(simplifed_df) == input$variants_feature_column] <- "feature_column" 66 | colnames(simplifed_df)[colnames(simplifed_df) == input$variants_gene_column] <- "gene_column" 67 | } 68 | 69 | need_splite_df <- as.data.frame(simplifed_df[(grepl(";", simplifed_df$gene_column) | grepl(";|&", simplifed_df$feature_column)),]) 70 | no_splite_df <- as.data.frame(simplifed_df[!(grepl(";", simplifed_df$gene_column) | grepl(";|&", simplifed_df$feature_column)) ,]) 71 | 72 | if(nrow(need_splite_df) > 0){ 73 | splited_df <- need_splite_df %>% tidyr::separate_rows(feature_column, sep = ";|&") %>% 74 | tidyr::separate_rows(gene_column, sep = ";") %>% unique() 75 | combined_df <- rbind(splited_df, no_splite_df) 76 | }else{ 77 | combined_df <- no_splite_df 78 | } 79 | combined_df <- combined_df %>% dplyr::group_by(feature_column, gene_column) %>% dplyr::count() 80 | combined_df <- combined_df[combined_df$feature_column %in% input$Variants_bar_position_ID, ] 81 | colnames(combined_df) <- c("Position", "Genes", "Numbers") 82 | combined_df <- combined_df[combined_df$Genes != "NONE", ] 83 | combined_df <- combined_df[combined_df$Genes != "", ] 84 | df <- combined_df %>% dplyr::group_by(Position, Genes) %>% summarise_at(.vars = "Numbers", sum) 85 | df <- df[order(df$Numbers, decreasing = T), ] 86 | return(df) 87 | }) 88 | 89 | # 2-2.2 对筛选突变的同一基因进行合并 90 | output$Variants_df <- DT::renderDataTable( 91 | Variants_genes(), 92 | options = list( 93 | scrollX = TRUE, 94 | pageLength = 5 95 | ) 96 | ) 97 | 98 | output$summary_gene_tab <- downloadHandler( 99 | filename = function() {paste0("7_Relevant Genes",".csv")}, 100 | content = function(file) { 101 | write.csv(Variants_genes(), file, row.names = F) 102 | } 103 | ) 104 | 105 | 106 | #2-2.3、 绘制突变基因柱状图 107 | Variants_plot <- eventReactive(input$plot_Variants_genes, { 108 | withProgress(message = "processing", min = 0, max = 1, { 109 | incProgress(0.4, detail = "Analyse Data ...") 110 | Variants_df <- Variants_genes() %>% group_by(Genes) %>% summarise_at(.vars = "Numbers", sum) 111 | Variants_df <- Variants_df[Variants_df$Genes != "",] 112 | Variants_genes <- Variants_df[order(Variants_df$Numbers, decreasing = T), ][1:input$Variants_genes_numbers, ] 113 | incProgress(0.6, detail = "Analyse Data...") 114 | p <- ggpubr::ggbarplot(Variants_genes, x = "Genes", y = "Numbers", label = as.logical(input$Variants_genes_label), 115 | width = input$Variants_genes_bar_width, position = position_dodge(), 116 | fill = "Genes", ggtheme = theme_classic())+ 117 | xlab(NULL) + ylab("Variants Genes Numbers of biotypes")+ 118 | theme(legend.position = "none", 119 | axis.text.x = element_text(angle = 45, hjust = 1), 120 | axis.text = element_text(color = "black", size = input$Variants_genes_label_text_size), 121 | axis.title = element_text(color = "black", size = input$Variants_genes_title_text_size), 122 | text = element_text(face = "bold", family = "Times", color = "black")) 123 | 124 | if (!is.null(input$variants_genes_ggText)){ 125 | add_funcs <- strsplit(input$variants_genes_ggText, "\\+")[[1]] 126 | p <- p + lapply(add_funcs, function(x){ 127 | eval(parse(text = x)) 128 | }) 129 | } 130 | incProgress(0.8, detail = "Analyse data...") 131 | return(p) 132 | }) 133 | }) 134 | 135 | output$Variants_Plots <- renderPlot({ 136 | Variants_plot() 137 | }) 138 | 139 | #2-2.4、 下载突变基因柱状图 140 | output$Variants_genes_Download <- downloadHandler( 141 | req(input$Variants_Genes_download_width, input$Variants_Genes_download_height), 142 | filename = function(){ 143 | paste(paste("7", input$Variants_sampleID,input$Variants_type_id, "Variants_Genes_Summerise_plot", sep = "_"), "pdf", sep = ".") 144 | }, 145 | content = function(file){ 146 | pdf(file, width = input$Variants_Genes_download_width, height = input$Variants_Genes_download_height) 147 | print(Variants_plot()) 148 | dev.off() 149 | } 150 | ) 151 | 152 | -------------------------------------------------------------------------------- /inst/shiny/modules/8.VariantsGene_Summarise_ui.R: -------------------------------------------------------------------------------- 1 | tabItem( 2 | tabName = "Variants_summarise", 3 | fluidRow( 4 | box( 5 | title = "Set Variants Genes Plot", width = 3, status = "info", collapsible = T, 6 | prettyRadioButtons(inputId = "Variants_type_id", label = "Variant type:", choices = c("all", "snp", "indel"), inline = T, 7 | animation = "tada", shape = "square", bigger = T), 8 | uiOutput("Variants_sample_id"), 9 | uiOutput("Variants_feature_column"), 10 | uiOutput("Variants_gene_column"), 11 | uiOutput("Variants_bar_position_id"), 12 | actionButton("variants_modules_id", "Set Additional Parameters ...", width = "100%", 13 | style = "background-color: rgb(255,255,255);text-align:left;margin-top:15px; margin-bottom:8px", 14 | icon = icon(lib ="glyphicon" ,"glyphicon glyphicon-cog")), 15 | actionButton("plot_Variants_genes", "Plot Variants Genes", 16 | style = "background-color: #76a5af; border-radius: 28px;", width = "100%") 17 | ), 18 | bsModal( 19 | "variants_modules", "Set Additional Parameters", "variants_modules_id", size = "small", 20 | fluidPage( 21 | style = "padding:10px", 22 | column( 23 | width = 12, 24 | radioGroupButtons("Variants_genes_label", "Display Barplot Numbers Label:", c(TRUE, FALSE), 25 | justified = T, checkIcon = list(yes = icon("ok",lib = "glyphicon")), width = "100%"), 26 | sliderInput("Variants_genes_numbers", "Display Top N Gene:", min = 0, max = 50, value = 20, step = 1, width = "100%"), 27 | sliderInput("Variants_genes_title_text_size", "Title text size:", min = 0, max = 30, value = 13, step = 1, width = "100%"), 28 | sliderInput("Variants_genes_label_text_size", "Label text size:", min = 0, max = 30, value = 12, step = 1, width = "100%"), 29 | sliderInput("Variants_genes_bar_width", "Bar Width:", min = 0, max = 5, value = 0.8, step = 0.1, width = "100%"), 30 | textAreaInput("variants_genes_ggText", "Add ggplot Codes:", rows = 5, width = "100%") 31 | ) 32 | ) 33 | ), 34 | box( 35 | title = "Display Variants Genes Plot", width = 9, status = "primary", collapsible = T, 36 | div( 37 | style = "position: absolute; right: 0.5em; top: 0.5em;", 38 | dropdown( 39 | label = "Set Download Plot Elements", width = "100%", right = T, icon = icon(name = "glyphicon glyphicon-save",lib = "glyphicon"), 40 | sliderInput("Variants_Genes_download_width", "Download Plot width", min = 0, max = 15, value = 7, step = 0.5, width = "100%"), 41 | sliderInput("Variants_Genes_download_height", "Download Plot Height", min = 0, max = 15, value = 4, step = 0.5, width = "100%"), 42 | h4("Download Plot"), 43 | downloadButton("Variants_genes_Download","Download Plot") 44 | ) 45 | ), 46 | div( 47 | shinycssloaders::withSpinner(plotOutput("Variants_Plots", height = "419px")) 48 | ) 49 | ), 50 | box( 51 | title = "Display Variants Genes Data", width = 12, status = "success", collapsible = T, 52 | div( 53 | style = "position: absolute; right:0.5em; top: 0.5em;", 54 | downloadButton('summary_gene_tab','Download CSV', class = "btn", icon = icon("download", lib = "glyphicon")) 55 | ), 56 | div( 57 | DT::dataTableOutput("Variants_df") 58 | ) 59 | ) 60 | ) 61 | ) 62 | -------------------------------------------------------------------------------- /inst/shiny/modules/9.VariantsGene_Heatmap_server.R: -------------------------------------------------------------------------------- 1 | 2 | #2-3、构建各组变异基因热图数据----------------------------------------------------------------------------------------------------------------------- 3 | output$Variants_heatmap_sampleID <- renderUI({ 4 | virtualSelectInput( 5 | inputId = "Variants_heatmap_sampleID", label = "Select samples:", 6 | choices = unique(gsub("\\..*","",names(raw_variants_list()))), 7 | selected = unique(gsub("\\..*","",names(raw_variants_list()))), 8 | multiple = T, search = F, width = "100%" 9 | ) 10 | }) 11 | 12 | output$Variants_heatmap_feature_column <- renderUI({ 13 | virtualSelectInput( 14 | inputId = "variants_heatmap_feature_column", label = "Select Genomic Feature Column:", 15 | choices = colnames(raw_variants_list()[[1]]), 16 | selected = colnames(raw_variants_list()[[1]])[6], multiple = F, search = F, width = "100%" 17 | ) 18 | }) 19 | 20 | output$Variants_heatmap_gene_column <- renderUI({ 21 | virtualSelectInput( 22 | inputId = "variants_heatmap_gene_column", label = "Select Related Gene Column:", 23 | choices = colnames(raw_variants_list()[[1]]), 24 | selected = colnames(raw_variants_list()[[1]])[7], multiple = F, search = F, width = "100%" 25 | ) 26 | }) 27 | 28 | #2-3.1、 构建选择位置输入框 29 | output$Variants_position_id <- renderUI({ 30 | if (input$Variants_heatmap_types == "all") { 31 | simplifed_df1 <- raw_variants_list()[paste0(input$Variants_heatmap_sampleID, ".indel")] %>% dplyr::bind_rows() 32 | simplifed_df2 <- raw_variants_list()[paste0(input$Variants_heatmap_sampleID, ".snp")] %>% dplyr::bind_rows() 33 | simplifed_df <- rbind(simplifed_df1, simplifed_df2) 34 | }else { 35 | simplifed_df <- raw_variants_list()[paste0(input$Variants_heatmap_sampleID, ".", input$Variants_heatmap_types)] %>% dplyr::bind_rows() 36 | } 37 | colnames(simplifed_df)[colnames(simplifed_df) == input$variants_heatmap_feature_column] <- "feature_column" 38 | no_splite_df <- as.data.frame(simplifed_df[grep(";|&", simplifed_df$feature_column, invert = T), ]) 39 | need_splite_df <- as.data.frame(simplifed_df[grep(";|&", simplifed_df$feature_column), ]) 40 | 41 | if(nrow(need_splite_df) > 0){ 42 | splited_df <- need_splite_df %>% tidyr::separate_rows(feature_column, sep = ";|&") %>% unique() 43 | combined_df <- rbind(no_splite_df, splited_df) 44 | }else{ 45 | combined_df <- no_splite_df 46 | } 47 | 48 | virtualSelectInput( 49 | inputId = "Variants_position_ID", label = "Select Position To Analyse:", 50 | choices = unique(combined_df$feature_column), selected = unique(combined_df$feature_column), multiple = T, zIndex = 4,search = F, width = "100%" 51 | ) 52 | }) 53 | 54 | 55 | 56 | Variants_heatmap_data <- eventReactive(input$Variants_heatmap, { 57 | Variants_heatmap_df <- lapply(input$Variants_heatmap_sampleID, function(x){ 58 | if (input$Variants_heatmap_types == "all") { 59 | simplifed_df1 <- raw_variants_list()[paste0(x, ".indel")] %>% dplyr::bind_rows() 60 | simplifed_df2 <- raw_variants_list()[paste0(x, ".snp")] %>% dplyr::bind_rows() 61 | simplifed_df <- rbind(simplifed_df1, simplifed_df2) 62 | colnames(simplifed_df)[colnames(simplifed_df) == input$variants_heatmap_feature_column] <- "feature_column" 63 | colnames(simplifed_df)[colnames(simplifed_df) == input$variants_heatmap_gene_column] <- "gene_column" 64 | }else { 65 | simplifed_df <- raw_variants_list()[paste0(x, ".", input$Variants_heatmap_types)] %>% dplyr::bind_rows() 66 | colnames(simplifed_df)[colnames(simplifed_df) == input$variants_heatmap_feature_column] <- "feature_column" 67 | colnames(simplifed_df)[colnames(simplifed_df) == input$variants_heatmap_gene_column] <- "gene_column" 68 | } 69 | 70 | need_splite_df <- as.data.frame(simplifed_df[(grepl(";", simplifed_df$gene_column) | grepl(";|&", simplifed_df$feature_column)) ,]) 71 | no_splite_df <- as.data.frame(simplifed_df[!(grepl(";", simplifed_df$gene_column) | grepl(";|&", simplifed_df$feature_column)) ,]) 72 | 73 | if(nrow(need_splite_df) > 0){ 74 | splited_df <- need_splite_df %>% tidyr::separate_rows(feature_column, sep = ";|&") %>% tidyr::separate_rows(gene_column, sep = ";") %>% unique() 75 | combined_df <- rbind(splited_df,no_splite_df) 76 | }else{ 77 | combined_df <- no_splite_df 78 | } 79 | combined_df <- combined_df %>% dplyr::group_by(feature_column, gene_column) %>% dplyr::count() 80 | combined_df <- combined_df[combined_df$feature_column %in% input$Variants_position_ID, ] 81 | colnames(combined_df) <- c("Position", "Genes", "Numbers") 82 | combined_df <- combined_df[combined_df$Genes != "NONE", ] 83 | combined_df <- combined_df[combined_df$Genes != "", ] 84 | 85 | combined_df <- combined_df %>% dplyr::group_by(Genes) %>% dplyr::summarise_at(.vars = "Numbers", sum) %>% as.data.frame() 86 | 87 | IntOGen <- readRDS(system.file("extdata", "IntOGen_cancer_driver_gene.rds", package = "VCFshiny")) 88 | combined_df <- combined_df[combined_df$Genes %in% IntOGen$Symbol, ] 89 | combined_df <- combined_df[order(combined_df$Numbers, decreasing = T), ] 90 | colnames(combined_df) <- c("Genes", x) 91 | combined_df <- na.omit(combined_df) 92 | }) %>% plyr::join_all(by = "Genes", type = "full") 93 | Variants_heatmap_df[is.na(Variants_heatmap_df)] <- 0 94 | return(Variants_heatmap_df) 95 | }) 96 | 97 | 98 | output$Variants_Heatmap_data <- DT::renderDataTable( 99 | return(Variants_heatmap_data()), 100 | options = list( 101 | scrollX = TRUE, 102 | pageLength = 5 103 | ) 104 | ) 105 | 106 | output$heatmap_gene_tab <- downloadHandler( 107 | filename = function() {paste0("8_Heatmap_info_table",".csv")}, 108 | content = function(file) { 109 | write.csv(Variants_heatmap_data(), file, row.names = F) 110 | } 111 | ) 112 | 113 | #2-3.2 、 绘制热图 114 | Heat_Plot_2 <- eventReactive(input$Variants_heatmap, { 115 | withProgress(message = "processing", min = 0, max = 1, { 116 | 117 | Variants_heatmap_data <- as.data.frame(Variants_heatmap_data()) 118 | Variants_heatmap_data <- Variants_heatmap_data %>% column_to_rownames(var = "Genes") 119 | 120 | pheatmap::pheatmap(Variants_heatmap_data, cluster_rows = F, cluster_cols = F, 121 | color = grDevices::colorRampPalette(c("GhostWhite", "red"))(50), 122 | show_rownames = as.logical(input$Variants_heatmap_show_rownames), 123 | show_colnames = as.logical(input$Variants_heatmap_show_colnames), 124 | breaks = c(seq(0, input$Variants_heatmap_colorValue, input$Variants_heatmap_colorValue / 50)), 125 | legend_breaks = seq(0, input$Variants_heatmap_colorValue, 2), 126 | legend_labels = c(seq(0, input$Variants_heatmap_colorValue - 2, 2) %>% as.character, paste0(input$Variants_heatmap_colorValue, "+"))) 127 | }) 128 | }) 129 | 130 | 131 | output$Heatmap_plot_2 <- renderPlot({ 132 | Heat_Plot_2() 133 | }) 134 | 135 | #2-3.3、 下载热图 136 | output$Variants_heatmap_Download <- downloadHandler( 137 | filename = function(){ 138 | paste(paste("8", input$Variants_heatmap_types, "Variants_Heatmap_Summerise_plot", sep = "_"), "pdf", sep = ".") 139 | }, 140 | content = function(file){ 141 | pdf(file, width = input$Variants_heatmap_download_width, height = input$Variants_heatmap_download_height) 142 | print(Heat_Plot_2()) 143 | dev.off() 144 | } 145 | ) 146 | -------------------------------------------------------------------------------- /inst/shiny/modules/9.VariantsGene_Heatmap_ui.R: -------------------------------------------------------------------------------- 1 | tabItem( 2 | tabName = "Variants_heatmap", 3 | fluidRow( 4 | box( 5 | title = "Set Variants Genes Heatmap Plot", width = 3, status = "info", collapsible = T, 6 | prettyRadioButtons(inputId = "Variants_heatmap_types", label = "Select Heatmap Data Types:", 7 | choices = c("all", "snp", "indel"), inline = T, 8 | animation = "tada", shape = "square", bigger = T), 9 | uiOutput("Variants_heatmap_sampleID"), 10 | uiOutput("Variants_heatmap_feature_column"), 11 | uiOutput("Variants_heatmap_gene_column"), 12 | uiOutput("Variants_position_id"), 13 | sliderInput("Variants_heatmap_colorValue", "Max Color value:", min = 0, max = 50, value = 10, width = "100%"), 14 | actionButton("variants_heatmap_module_id", "Set Additional Parameters ...", width = "100%", 15 | style = "background-color: rgb(255,255,255);text-align:left;margin-top:15px; margin-bottom:8px", 16 | icon = icon(lib ="glyphicon" ,"glyphicon glyphicon-cog")), 17 | actionButton("Variants_heatmap", "Variants Genes Heatmap", 18 | style = "background-color: #76a5af; border-radius: 28px;", width = "100%") 19 | ), 20 | bsModal( 21 | "variants_heatmap_module", "Set Additional Parameters", "variants_heatmap_module_id", size = "small", 22 | fluidPage( 23 | style = "padding:10px", 24 | radioGroupButtons("Variants_heatmap_show_rownames", "Show Rownames", choices = c("TRUE", "FALSE"), 25 | selected = "FALSE", justified = T, checkIcon = list(yes = icon("ok", lib = "glyphicon")), width = "100%"), 26 | radioGroupButtons("Variants_heatmap_show_colnames", "Show Colnames", choices = c("TRUE", "FALSE"), 27 | selected = "TRUE", justified = T, checkIcon = list(yes = icon("ok", lib = "glyphicon")), width = "100%"), 28 | ) 29 | ), 30 | box( 31 | title = "Display Heatmap Plot", width = 9, status = "primary", collapsible = T, 32 | div( 33 | style = "position: absolute; right:0.5em; top: 0.5em;", 34 | dropdown( 35 | label = "Set Download Plot Elements", width = "100%", right = T, icon = icon(name = "glyphicon glyphicon-save",lib = "glyphicon"), 36 | sliderInput("Variants_heatmap_download_width", "Download Plot width", min = 0, max = 15, value = 6, step = 0.5, width = "100%"), 37 | sliderInput("Variants_heatmap_download_height", "Download Plot Height", min = 0, max = 15, value = 4, step = 0.5, width = "100%"), 38 | h4("Download Plot"), 39 | downloadButton("Variants_heatmap_Download","Download Plot") 40 | ) 41 | ), 42 | div( 43 | shinycssloaders::withSpinner(plotOutput("Heatmap_plot_2", height = "528px")) 44 | ) 45 | ), 46 | box( 47 | title = "Display Heatmap Data", width = 12, status = "success", collapsible = T, 48 | div( 49 | style = "position: absolute; right:0.5em; top: 0.5em;", 50 | downloadButton('heatmap_gene_tab','Download CSV', class = "btn", icon = icon("download", lib = "glyphicon")) 51 | ), 52 | div( 53 | DT::dataTableOutput("Variants_Heatmap_data") 54 | ) 55 | ) 56 | ) 57 | ) 58 | -------------------------------------------------------------------------------- /inst/shiny/www/custom.css: -------------------------------------------------------------------------------- 1 | .col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-xs-1, .col-xs-10, .col-xs-11, .col-xs-12, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9 { 2 | position: relative; 3 | min-height: 1px; 4 | padding-right: 5px; 5 | padding-left: 5px; 6 | } 7 | 8 | 9 | /*----------------box-------------------------*/ 10 | .box { 11 | padding-left: 0px; 12 | padding-right: 0px; 13 | margin-left: 0px; 14 | margin-right: 0px; 15 | } 16 | 17 | .box > div.box-header { 18 | background-color: white; 19 | border-top-right-radius: 5px; 20 | border-top-left-radius: 5px; 21 | border-left: 1px solid rgb(224,224,224); 22 | border-right: 1px solid rgb(224,224,224); 23 | border-top: 1px solid rgb(224,224,224); 24 | border-bottom: 1px solid rgb(224,224,224); 25 | } 26 | 27 | .box > div.box-header > h3 { 28 | color: black; 29 | font-size: 900; 30 | } 31 | 32 | /*#preview_mat_card > div > div > div.box-header > h3 { 33 | color: white; 34 | }*/ 35 | 36 | .box > div.box-body { 37 | border-left: 1px solid rgb(224,224,224); 38 | border-right: 1px solid rgb(224,224,224); 39 | border-bottom: 1px solid rgb(224,224,224); 40 | border-bottom-right-radius: 5px; 41 | border-bottom-left-radius: 5px; 42 | /* 43 | box-shadow: 0 5px 5px -5px rgba(0, 0, 0, 0.5), 44 | 0 1px 4px rgba(0, 0, 0, 0.3), 45 | 0 0 10px rgba(0, 0, 0, 0.1) inset; 46 | */ 47 | } 48 | 49 | .box-header > div > button { 50 | color: rgb(87, 96, 106); 51 | /*background-color: rgb(87, 96, 106);*/ 52 | } 53 | 54 | 55 | div.box-body .shiny-input-container { 56 | width: auto; 57 | margin-bottom: 8px; 58 | } 59 | 60 | .progress.shiny-file-input-progress { 61 | visibility: 0; 62 | margin-bottom: 0; 63 | } 64 | 65 | .btn-upload { 66 | background: -webkit-linear-gradient(90deg,rgb(222,222,222) 50%,rgb(245,245,245) 100%); 67 | /*-webkit-gradient(linear, left top, right bottom, from(rgb(222,222,222)), to(rgb(245,245,245)));*/ 68 | /*background-color: rgb(148, 172, 206);*/ 69 | border-radius: 10px; 70 | transition-duration: 0.4s; 71 | height: 40px; 72 | color: rgb(63,138,198); 73 | /*font-size: 20px;*/ 74 | font-weight: 800; 75 | font-family: Times New Roman; 76 | } 77 | 78 | .content { 79 | overflow: visible; 80 | background-color: white; 81 | } 82 | 83 | .btn-default > i { 84 | padding-right: 10px; 85 | } 86 | 87 | #input_file-label { 88 | padding-top: 15px; 89 | } 90 | 91 | #shiny-tab-ALL_variants > div > div.col-sm-3 > div > div.box-body > div.form-group.shiny-input-container.shiny-input-radiogroup.shiny-input-container-inline { 92 | padding-top: 10px; 93 | } 94 | 95 | #ALL_Variants_plot_label-label { 96 | padding-top: 10px; 97 | } 98 | 99 | .sbs-modal > div { 100 | width: 400px; 101 | } 102 | 103 | .sw-dropdown > sw-dropdown-content > sw-dropdown-in > a { 104 | padding-left: 30px; 105 | padding-right: 30px; 106 | } 107 | 108 | -------------------------------------------------------------------------------- /inst/shiny/www/radar_style.css: -------------------------------------------------------------------------------- 1 | .btn-success { 2 | font-size: 18px; 3 | font-family: inherit; 4 | padding: 5px 12px; 5 | height: 55px; 6 | min-width: 21.85%; 7 | margin: 0px 10px 14px 20px; 8 | text-align: left; 9 | color: white; 10 | background: #727477; 11 | text-indent: 4px; 12 | vertical-align: middle; 13 | border-radius: 0px; 14 | border-color: transparent; 15 | box-shadow: 0 2px 5px 0 rgba(0,0,0,0.18), 0 1px 5px 0 rgba(0,0,0,0.15); 16 | text-transform: uppercase; 17 | -webkit-transition: all 0.25s cubic-bezier(0.02, 0.01, 0.47, 1); 18 | transition: all 0.25s cubic-bezier(0.02, 0.01, 0.47, 1); 19 | -webkit-transform: translate3d(0, 0, 0); 20 | transform: translate3d(0, 0, 0); 21 | } 22 | .btn-success:hover { 23 | background-color:#d1351b; 24 | font-size: 18px; 25 | font-family: inherit; 26 | padding: 5px 12px; 27 | height: 55px; 28 | min-width: 21.85%; 29 | margin: 0px 10px 14px 20px; 30 | text-align: left; 31 | color: white; 32 | text-indent: 4px; 33 | vertical-align: middle; 34 | border-radius: 0px; 35 | border-color: transparent; 36 | box-shadow: 0 5px 11px 0 rgba(0,0,0,0.18), 0 4px 15px 0 rgba(0,0,0,0.15); 37 | -webkit-transition: box-shadow 0.4s ease-out; 38 | transition: box-shadow 0.4s ease-out; 39 | } 40 | .btn-warning, .btn-warning:hover { 41 | font-size: 18px; 42 | font-family: inherit; 43 | padding: 5px 12px; 44 | height: 55px; 45 | min-width: 21.85%; 46 | margin: 0px 10px 14px 20px; 47 | text-align: left; 48 | color: white; 49 | background: #d1351b; 50 | text-indent: 4px; 51 | vertical-align: middle; 52 | border-radius: 0px; 53 | border-color: transparent; 54 | box-shadow: 0 2px 5px 0 rgba(0,0,0,0.18), 0 1px 5px 0 rgba(0,0,0,0.15); 55 | text-transform: uppercase; 56 | -webkit-transition: all 0.25s cubic-bezier(0.02, 0.01, 0.47, 1); 57 | transition: all 0.25s cubic-bezier(0.02, 0.01, 0.47, 1); 58 | -webkit-transform: translate3d(0, 0, 0); 59 | transform: translate3d(0, 0, 0); 60 | } 61 | .fa { 62 | margin-right: 10px; 63 | } 64 | .fa.fa-gear.opt { 65 | margin-right: 0px; 66 | } 67 | .fa.fa-search-plus.opt { 68 | margin-right: 0px 69 | } 70 | #intro { 71 | margin-bottom: 0; 72 | align-items: center; 73 | display: block; 74 | margin: 0 auto; 75 | background: #d1351b; 76 | color: white; 77 | min-width: 25%; 78 | border-color: white 79 | } 80 | #sidebar_button { 81 | height: 55px; 82 | } 83 | section.sidebar .shiny-bound-input.action-button, section.sidebar .shiny-bound-input.action-link { 84 | margin: auto; 85 | display: block; 86 | } 87 | .btn-danger { 88 | background-color: #d1351b; 89 | border-color: #d1351b; 90 | height: 55px; 91 | width: 300px; 92 | border-radius: 0; 93 | position: relative; 94 | font-size: 18px; 95 | } 96 | .btn-primary { 97 | background-color: darkgrey; 98 | border-color: darkgrey; 99 | color: white; 100 | height: 55px; 101 | width: 300px; 102 | border-radius: 0; 103 | position: relative; 104 | font-size: 18px; 105 | } 106 | .btn-primary:hover { 107 | background-color: #d1351b; 108 | border-color: #d1351b; 109 | color: white; 110 | border-color: #d1351b; 111 | 112 | } 113 | .fa.fa-user, .fa.fa-thumbs-o-up, .fa.fa-flask.flask-box, .fa.fa-spinner.spinner-box { 114 | color: white; 115 | font-size: 20; 116 | margin-right: 10px; 117 | font-size: 30px; 118 | vertical-align: middle; 119 | } 120 | 121 | .skin-black .treeview-menu > li > a { 122 | color: white; 123 | white-space: pre-line; 124 | } 125 | .skin-black .treeview-menu > li:hover > a { 126 | color: white; 127 | white-space: pre-line; 128 | background-color:#606164;; 129 | } 130 | 131 | 132 | .info-box { 133 | min-height:55px; 134 | float:center; 135 | box-shadow:5px 5px 5px lightgrey; 136 | border-bottom: 0px; 137 | } 138 | } 139 | .info-box-icon.bg-black { 140 | height:55px; 141 | } 142 | .bg-black { 143 | background-color: #727477 !important; 144 | height: 55px; 145 | line-height:55px; 146 | 147 | } 148 | .text-success { 149 | color: #d1351b; 150 | font-size: large; 151 | 152 | } 153 | .skin-black .main-header .navbar { 154 | background-color:#d1351b 155 | } 156 | .skin-black .main-header .navbar .nav > li > a { 157 | color:#fff 158 | } 159 | .skin-black .main-header .navbar .nav > li > a:hover { 160 | background:#ffffff; 161 | color:#d1351b 162 | } 163 | .skin-black .main-header .navbar .sidebar-toggle { 164 | color:#ffffff 165 | } 166 | .skin-black .main-header .navbar .sidebar-toggle:hover { 167 | color:#d1351b; 168 | background:#fff 169 | } 170 | .skin-black .main-header .navbar .navbar-custom-menu .navbar-nav > li > a, .skin-black .main-header .navbar .navbar-right > li > a { 171 | border-left:1px solid #d1351b; 172 | border-right-width:0 173 | } 174 | .main-header .logo { 175 | font-family:"Helvetica Neue", sans-serif ; 176 | font-weight:bold; 177 | letter-spacing:-1px; 178 | font-size:30px; 179 | color:#ffffff; 180 | } 181 | .modal-dialog{ 182 | max-width:1000px; 183 | border-radius: 5px; 184 | border: 2px solid white; 185 | } 186 | .modal-body{ 187 | max-height:700px; 188 | align-content:center; 189 | border: 2px solid white; 190 | border-radius: 5px; 191 | } 192 | .modal-sm { 193 | max-width:1200px; 194 | align-content:center; 195 | border-radius: 5px; 196 | border: 2px solid white; 197 | } 198 | .sidebar { 199 | height:90vh; 200 | overflow-y:auto 201 | } 202 | .skin-black .main-header > .logo { 203 | background-color:#d1351b; 204 | color:#ffffff; 205 | border-bottom:0 solid transparent; 206 | border-right:1px solid #d1351b; 207 | } 208 | .skin-black .main-header > .logo:hover { 209 | background-color:#d1351b 210 | } 211 | .nav-tabs-custom > .nav-tabs > li.active { 212 | border-top-color:#616365 213 | } 214 | .nav-tabs-custom { 215 | box-shadow:5px 5px 5px lightgrey 216 | } 217 | .skin-black .left-side, .skin-black .main-sidebar, .skin-black .wrapper { 218 | background-color:#727477; 219 | } 220 | .skin-black .sidebar-menu > li.active > a, .skin-black .sidebar-menu > li:hover > a { 221 | color:#fff; 222 | background:#606164; 223 | border-left-color:#d1351b; 224 | } 225 | .skin-black .sidebar-menu > li > .treeview-menu { 226 | margin:0 1px; 227 | background:#8a8c8f; 228 | box-shadow:inset 0px 0px 7px #000000; 229 | padding-bottom:2px 230 | } 231 | .skin-black .sidebar a { 232 | color:#ffffff 233 | } 234 | .navbar-nav > .messages-menu > .dropdown-menu, .navbar-nav > .notifications-menu > .dropdown-menu, .navbar-nav > .tasks-menu > .dropdown-menu { 235 | width: 400px; 236 | padding: 0; 237 | margin: 10px; 238 | top: 100%; 239 | background-color: #fefefee6; 240 | box-shadow: 10px 10px 10px darkgrey; 241 | } 242 | .navbar-nav > .messages-menu > .dropdown-menu > li.header, .navbar-nav > .notifications-menu > .dropdown-menu > li.header, .navbar-nav > .tasks-menu > .dropdown-menu > li.header { 243 | border-top-left-radius: 0px; 244 | border-top-right-radius: 0px; 245 | border-bottom-right-radius: 0; 246 | border-bottom-left-radius: 0; 247 | background-color: #d1351b; 248 | padding: 7px 10px; 249 | border-bottom: 1px solid #d1351be6; 250 | color: #ffffff; 251 | font-size: 14px; 252 | } 253 | .navbar-nav > .messages-menu > .dropdown-menu > li .menu, .navbar-nav > .notifications-menu > .dropdown-menu > li .menu, .navbar-nav > .tasks-menu > .dropdown-menu > li .menu { 254 | max-height: 1200px; 255 | margin: 0; 256 | padding: 0; 257 | list-style: none; 258 | overflow-x: hidden; 259 | } 260 | .navbar-nav > .notifications-menu > .dropdown-menu > li .menu > li > a { 261 | color: #000000; 262 | overflow: hidden; 263 | white-space: normal; 264 | } 265 | #coxreg { 266 | overflow-y: auto; 267 | max-height: 200px; 268 | background-color: lightgrey; 269 | box-shadow: inset 0px -5px 5px darkgrey 270 | } 271 | #coxreg_aic { 272 | background-color: lightgrey 273 | } 274 | #logreg { 275 | overflow-y: auto; 276 | max-height: 200px; 277 | background-color: lightgrey; 278 | box-shadow: inset 0px -5px 5px darkgrey 279 | } 280 | #logreg_aic { 281 | background-color: lightgrey 282 | } 283 | .shiny-output-error { 284 | visibility: hidden; 285 | } 286 | .shiny-output-error:before { 287 | visibility: hidden; 288 | } 289 | -------------------------------------------------------------------------------- /man/VCFserver.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/VCFserver.R 3 | \name{VCFserver} 4 | \alias{VCFserver} 5 | \title{create the server functions} 6 | \usage{ 7 | VCFserver(input, output, session) 8 | } 9 | \arguments{ 10 | \item{input}{shiny input} 11 | 12 | \item{output}{shiny output} 13 | 14 | \item{session}{shiny session} 15 | } 16 | \description{ 17 | create the server functions 18 | } 19 | -------------------------------------------------------------------------------- /man/VCFui.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/VCFui.R 3 | \name{VCFui} 4 | \alias{VCFui} 5 | \title{Build shiny UI page} 6 | \usage{ 7 | VCFui() 8 | } 9 | \description{ 10 | Build shiny UI page 11 | } 12 | -------------------------------------------------------------------------------- /man/hello.Rd: -------------------------------------------------------------------------------- 1 | \name{hello} 2 | \alias{hello} 3 | \title{Hello, World!} 4 | \usage{ 5 | hello() 6 | } 7 | \description{ 8 | Prints 'Hello, world!'. 9 | } 10 | \examples{ 11 | hello() 12 | } 13 | -------------------------------------------------------------------------------- /man/startVCFshiny.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/runApp.R 3 | \name{startVCFshiny} 4 | \alias{startVCFshiny} 5 | \title{Start the VCFshiny shiny App} 6 | \usage{ 7 | startVCFshiny( 8 | launch.browser = TRUE, 9 | port = getOption("shiny.port"), 10 | host = getOption("shiny.host", "127.0.0.1") 11 | ) 12 | } 13 | \description{ 14 | Start the VCFshiny shiny App 15 | } 16 | --------------------------------------------------------------------------------