### Install ggcoverage from GitHub Source: https://github.com/showteeth/ggcoverage/blob/main/docs/index.html Install the ggcoverage package directly from its GitHub repository for the latest updates. Ensure 'remotes' is installed first if needed. ```r # install via Github # install.package("remotes") #In case you have not installed it. remotes::install_github("showteeth/ggcoverage") ``` -------------------------------- ### Install ggcoverage Package Source: https://github.com/showteeth/ggcoverage/blob/main/README.md Install the ggcoverage package from CRAN or GitHub. GitHub installation is recommended for the latest updates. ```r install.packages("ggcoverage") ``` ```r install.package("remotes") remotes::install_github("showteeth/ggcoverage") ``` -------------------------------- ### Create Coverage Plot Example Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/ggcoverage.html Example demonstrating how to load track data and create a coverage plot using ggcoverage. Ensure necessary libraries are loaded and data is prepared with LoadTrackFile. ```R # library(ggcoverage) # library(utils) # library(rtracklayer) # meta.file <- system.file("extdata", "RNA-seq", "meta_info.csv", package = "ggcoverage") # sample.meta <- utils::read.csv(meta.file) # track folder # track.folder <- system.file("extdata", "RNA-seq", package = "ggcoverage") # load bigwig file # track.df <- LoadTrackFile(track.folder = track.folder, format = "bw",region = "chr14:21,677,306-21,737,601", # extend = 2000, meta.info = sample.meta) # gtf.file <- system.file("extdata", "used_hg19.gtf", package = "ggcoverage") # gtf.gr <- rtracklayer::import.gff(con = gtf.file, format = "gtf") # ggcoverage(data = track.df, color = "auto", range.position = "out") ``` -------------------------------- ### Example Usage of ggprotein Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/ggprotein.html Demonstrates how to use the ggprotein function with example file paths and a protein ID. Ensure the necessary library is loaded and the file paths are correctly set. ```R # library(ggcoverage) # coverage.file <- system.file("extdata", "Proteomics", "MS_BSA_coverage.xlsx", package = "ggcoverage") # fasta.file <- system.file("extdata", "Proteomics", "MS_BSA_coverage.fasta", package = "ggcoverage") # protein.id = "sp|P02769|ALBU_BOVIN" # ggprotein(coverage.file = coverage.file, fasta.file = fasta.file, protein.id = protein.id) ``` -------------------------------- ### Install ggcoverage from GitHub Source: https://github.com/showteeth/ggcoverage/blob/main/docs/articles/ggcoverage.html Install the ggcoverage package from its GitHub repository for the latest updates. It's recommended over CRAN for more timely updates. Ensure GenomeMatrix is installed if dependency errors occur. ```R # install via Github (v1.2.0) # install.package("remotes") #In case you have not installed it. # BiocManager::install("areyesq89/GenomeMatrix") # In case of possible dependency error remotes::install_github("showteeth/ggcoverage") ``` -------------------------------- ### Get Consensus Peak from Replicates Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/GetConsensusPeak.html This example demonstrates how to use the GetConsensusPeak function to obtain consensus peaks from a specified peak file. Ensure the ggcoverage library is loaded. ```R # library(ggcoverage) # peak.file <- system.file("extdata", "ChIP-seq", "consensus.peak", package = "ggcoverage") # peak.df <- GetConsensusPeak(peak.file = peak.file) ``` -------------------------------- ### Load and Prepare FASTA Data Source: https://github.com/showteeth/ggcoverage/blob/main/docs/articles/ggcoverage.html Loads protein sequences from a FASTA file using Biostrings and prepares them for coverage analysis. Ensure Biostrings is installed. ```R library(Biostrings) # prepare track dataframe protein.set <- Biostrings::readAAStringSet(fasta.file) ``` -------------------------------- ### Example Usage of geom_cnv with ggcoverage Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/geom_cnv.html Demonstrates how to prepare CNV and track data, then plot it using ggcoverage with geom_cnv, geom_gc, and geom_ideogram for comprehensive visualization. ```R # library(ggcoverage) # library(utils) # library("BSgenome.Hsapiens.UCSC.hg19") # # prepare files # cnv.file <- system.file("extdata", "DNA-seq", "SRR054616_copynumber.txt", package = "ggcoverage") # track.file <- system.file("extdata", "DNA-seq", "SRR054616.bw", package = "ggcoverage") # # read CNV # cnv.df = read.table(file = cnv.file, sep = "\t", header = TRUE) # # load track # track.df = LoadTrackFile(track.file = track.file, format = "bw") # track.df$seqnames = paste0("chr", track.df$seqnames) # # plot # ggcoverage(data = track.df, color = "grey", region = "chr4:1-160000000", # mark.region = NULL, range.position = "out") + # geom_gc(bs.fa.seq=BSgenome.Hsapiens.UCSC.hg19) + # geom_cnv(cnv.df = cnv.df, bin.col = 3, cn.col = 4) + # geom_ideogram(genome = "hg19",plot.space = 0, highlight.centromere = TRUE) ``` -------------------------------- ### Install ggcoverage from CRAN Source: https://github.com/showteeth/ggcoverage/blob/main/docs/index.html Install the ggcoverage package from the Comprehensive R Archive Network (CRAN). ```r install.packages("ggcoverage") ``` -------------------------------- ### Load ggcoverage and dependencies Source: https://github.com/showteeth/ggcoverage/blob/main/docs/index.html Load the ggcoverage package along with necessary libraries like rtracklayer and ggpattern after installation. ```r library("rtracklayer") library("ggcoverage") library("ggpattern") ``` -------------------------------- ### ggcoverage with geom_base Example Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/geom_base.html Demonstrates how to use geom_base to add base and amino acid annotations to a ggcoverage plot. This example loads track data, creates a base ggcoverage plot, and then overlays the base annotations using geom_base with a specified BAM file and BSgenome. ```R # library(ggcoverage) # library("BSgenome.Hsapiens.UCSC.hg19") # get sample metadata # sample.meta <- data.frame( # SampleName = c("tumorA.chr4.selected"), # Type = c("tumorA"), Group = c("tumorA") # ) # get bam file # bam.file <- system.file("extdata", "DNA-seq", "tumorA.chr4.selected.bam", package = "ggcoverage") # load bam file # track.df <- LoadTrackFile( # track.file = bam.file, # meta.info = sample.meta, single.nuc = TRUE, # single.nuc.region = "chr4:62474235-62474295" # ) # ggcoverage( # data = track.df, color = "grey", range.position = "out", # single.nuc = TRUE, rect.color = "white" # ) + # geom_base( # bam.file = bam.file, # bs.fa.seq = BSgenome.Hsapiens.UCSC.hg19 # ) ``` -------------------------------- ### Load Libraries for ggcoverage Source: https://github.com/showteeth/ggcoverage/blob/main/docs/articles/CustomizeThePlot.html Load necessary libraries for plotting and data manipulation with ggcoverage. Ensure these are installed before running. ```R library(ggplot2) library(patchwork) library(tidyverse) library(ggcoverage) library(rtracklayer) ``` -------------------------------- ### Basic Protein Coverage Plot Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/geom_protein.html This example demonstrates how to create a basic protein coverage plot using geom_protein. Ensure the necessary libraries are loaded and file paths are correctly specified. ```R # library(ggplot2) # library(ggcoverage) # coverage.file <- system.file("extdata", "Proteomics", "MS_BSA_coverage.xlsx", package = "ggcoverage") # fasta.file <- system.file("extdata", "Proteomics", "MS_BSA_coverage.fasta", package = "ggcoverage") # protein.id = "sp| # ggplot() + # geom_peptide(coverage.file = coverage.file, fasta.file = fasta.file, protein.id = protein.id) ``` -------------------------------- ### Load ggcoverage Package Source: https://github.com/showteeth/ggcoverage/blob/main/README.md Load the ggcoverage package into your R session after installation. ```r library("ggcoverage") ``` -------------------------------- ### Basic Coverage Plot with geom_coverage Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/geom_coverage.html This example demonstrates how to create a basic coverage plot using geom_coverage. It requires loading track data and then using ggplot to add the coverage layer. Ensure the necessary libraries are loaded. ```r library(ggcoverage) library(utils) library(ggplot2) meta.file <- system.file("extdata", "RNA-seq", "meta_info.csv", package = "ggcoverage") sample.meta <- utils::read.csv(meta.file) track folder track.folder <- system.file("extdata", "RNA-seq", package = "ggcoverage") load bigwig file track.df <- LoadTrackFile( track.folder = track.folder, format = "bw", meta.info = sample.meta ) ggplot() + geom_coverage(data = track.df, color = "auto", mark.region = NULL) ``` -------------------------------- ### Prepare Mark Regions for Plotting Source: https://github.com/showteeth/ggcoverage/blob/main/docs/index.html Creates a data frame defining specific regions with start, end, and label for marking on coverage plots. ```R # create mark region mark.region=data.frame(start=c(21678900,21732001,21737590), end=c(21679900,21732400,21737650), label=c("M1", "M2", "M3")) # check data mark.region ``` -------------------------------- ### Get consensus peaks from replicates Source: https://github.com/showteeth/ggcoverage/blob/main/docs/articles/ggcoverage.html Load peak files and use `GetConsensusPeak` to obtain consensus peaks from ChIP-seq replicates. This step requires the MSPC package. ```R # load peak file peak.file <- system.file("extdata", "ChIP-seq", "consensus.peak", package = "ggcoverage") # get consensus peak (do nothing when there is only one file) # notice: this step requires MSPC, specific the installation path with mspc.path peak.df <- GetConsensusPeak(peak.file = peak.file) ``` -------------------------------- ### Prepare Mark Region Data Frame Source: https://github.com/showteeth/ggcoverage/blob/main/README.md Creates a data frame to define specific genomic regions for marking on the plot. Ensure the 'start', 'end', and 'label' columns are correctly populated. ```r # create mark region mark_region <- data.frame( start = c(21678900, 21732001, 21737590), end = c(21679900, 21732400, 21737650), label = c("M1", "M2", "M3") ) # check data mark_region ``` -------------------------------- ### FormatTrack() Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/index.html Prepares input data for creating coverage plots. ```APIDOC ## FormatTrack() ### Description Prepare Input for Creating Coverage Plot. ### Function Signature FormatTrack() ``` -------------------------------- ### R Session Information Source: https://github.com/showteeth/ggcoverage/blob/main/docs/articles/ggcoverage.html Displays the R version, platform, locale, attached base packages, and other attached packages, including their versions. ```R sessionInfo() ``` -------------------------------- ### List files in test directory Source: https://github.com/showteeth/ggcoverage/blob/main/docs/articles/TimeAndMemory.html Lists files in the 'test' directory, typically used to inspect data for sequential normalization. ```bash # test the sequential normalization ls -lh ./test #> total 2.0G #> -rw-r--r--. 1 songyabing wanglab 3.9M May 26 16:44 SRR054616_rep3.bam.bai #> -rw-r--r--. 1 songyabing wanglab 3.9M May 26 16:44 SRR054616_rep2.bam.bai #> -rw-r--r--. 1 songyabing wanglab 3.9M May 26 16:44 SRR054616_rep1.bam.bai #> -rw-r--r--. 1 songyabing wanglab 646M May 26 16:44 SRR054616_rep3.bam #> -rw-r--r--. 1 songyabing wanglab 646M May 26 16:44 SRR054616_rep2.bam #> -rw-r--r--. 1 songyabing wanglab 646M May 26 16:44 SRR054616_rep1.bam ``` -------------------------------- ### Basic Coverage Plot with GC Annotation Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/geom_gc.html Demonstrates how to create a basic coverage plot and add GC content annotation using geom_gc. Requires loading necessary libraries and preparing track data. ```R # library(ggcoverage) # library(utils) # library(rtracklayer) # library("BSgenome.Hsapiens.UCSC.hg19") # track folder # track.file <- system.file("extdata", "DNA-seq", "CNV_example.txt", package = "ggcoverage") # track.df <- utils::read.table(track.file, header = TRUE) # gtf.file <- system.file("extdata", "used_hg19.gtf", package = "ggcoverage") # gtf.gr <- rtracklayer::import.gff(con = gtf.file, format = "gtf") # basic.coverage <- ggcoverage( # data = track.df, color = NULL, mark.region = NULL, # region = "chr4:61750000-62,700,000", range.position = "out" # ) # basic.coverage + geom_gc(bs.fa.seq = BSgenome.Hsapiens.UCSC.hg19) ``` -------------------------------- ### Load Genome Data for GC Annotations Source: https://github.com/showteeth/ggcoverage/blob/main/README.md Loads the BSgenome.Hsapiens.UCSC.hg19 package, which is required for plotting GC content annotations. This package needs to be installed separately. ```r # load genome data library("BSgenome.Hsapiens.UCSC.hg19") ``` -------------------------------- ### List files in test2 directory Source: https://github.com/showteeth/ggcoverage/blob/main/docs/articles/TimeAndMemory.html Lists files in the 'test2' directory, typically used to inspect data for parallel normalization. ```bash # test the parallel normalization ls -lh ./test2 #> total 2.0G #> -rw-r--r--. 1 songyabing wanglab 3.9M May 26 16:44 SRR054616_rep3.bam.bai #> -rw-r--r--. 1 songyabing wanglab 3.9M May 26 16:44 SRR054616_rep2.bam.bai #> -rw-r--r--. 1 songyabing wanglab 3.9M May 26 16:44 SRR054616_rep1.bam.bai #> -rw-r--r--. 1 songyabing wanglab 646M May 26 16:44 SRR054616_rep3.bam #> -rw-r--r--. 1 songyabing wanglab 646M May 26 16:44 SRR054616_rep2.bam #> -rw-r--r--. 1 songyabing wanglab 646M May 26 16:44 SRR054616_rep1.bam ``` -------------------------------- ### Prepare mark region for ChIP-seq data Source: https://github.com/showteeth/ggcoverage/blob/main/docs/articles/ggcoverage.html Create a data frame defining a region to be marked on the coverage plot, including start, end, and a label. ```R # create mark region mark.region=data.frame(start=c(76822533), end=c(76823743), label=c("Promoter")) # check data mark.region ``` -------------------------------- ### Load and Prepare Hi-C Bin Table Source: https://github.com/showteeth/ggcoverage/blob/main/README.md Reads Hi-C bin data from a tab-separated file, assigns column names, and converts it into a GRanges object. ```r ## bin hic_bin_file <- system.file("extdata", "HiC", "HiC_bin.txt", package = "ggcoverage") hic_bin <- read.table(file = hic_bin_file, sep = "\t") colnames(hic_bin) <- c("chr", "start", "end") hic_bin_gr <- GenomicRanges::makeGRangesFromDataFrame(df = hic_bin) ``` -------------------------------- ### Define and Prepare Mark Region Source: https://github.com/showteeth/ggcoverage/blob/main/docs/articles/CustomizeThePlot.html Define a specific genomic region for marking on the plot, including start and end coordinates and a label. This region can be highlighted in the coverage plot. ```R # create mark region mark.region=data.frame(start=c(76822533), end=c(76823743), label=c("Promoter")) # check data mark.region ``` -------------------------------- ### Parallel normalization using LoadTrackFile Source: https://github.com/showteeth/ggcoverage/blob/main/docs/articles/TimeAndMemory.html Performs parallel normalization of BAM files using LoadTrackFile with multiple cores. This method is significantly faster than sequential normalization. Requires sample metadata and specifies the track folder, format, normalization method, region, bamCoverage path, extension, and the number of cores. ```r # prepare sample metadata sample.meta = data.frame(SampleName=c('SRR054616_rep1','SRR054616_rep2','SRR054616_rep3'), Type = c("SRR054616_rep1","SRR054616_rep2","SRR054616_rep3"), Group = c("rep1", "rep2", "rep3")) sample.meta # track folder track.folder = "./test2" # run with three cores system.time(track.df <- LoadTrackFile( track.folder = track.folder, format = "bam", norm.method = "RPKM", region = "14:21,677,306-21,737,601", bamcoverage.path = "~/anaconda3/bin/bamCoverage", extend = 2000, meta.info = sample.meta, n.cores = 3 )) #> user system elapsed #> 1191.628 36.818 424.143 ``` -------------------------------- ### Create and Customize Patchwork Object Source: https://github.com/showteeth/ggcoverage/blob/main/docs/articles/CustomizeThePlot.html Combine multiple ggcoverage plots into a single graphic using the patchwork package. This example adds gene and ideogram tracks to a base coverage plot. ```R # get consensus peak file peak.file = system.file("extdata", "ChIP-seq", "consensus.peak", package = "ggcoverage") # example plot chip.coverage = basic.coverage + labs(title = "chr18:76,822,285-76,900,000") + theme(plot.title=element_text(hjust=0.5)) + geom_gene(gtf.gr=gtf.gr, arrow.length = 0.04,arrow.size=0.25, gene.size = 0.75, utr.size = 1.5, exon.size = 2.5,label.size = 2.5, plot.height = 0.3) + geom_peak(bed.file = peak.file, plot.height = 0.1) + geom_ideogram(genome = "hg19",plot.space = 0, plot.height = 0.15) ``` -------------------------------- ### geom_gc Function Definition Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/geom_gc.html Defines the geom_gc function for adding GC content annotation. It accepts parameters for FASTA files, BSgenome objects, splitting characters, guide lines, colors, and plot dimensions. ```R geom_gc( fa.file = NULL, bs.fa.seq = NULL, chr.split = "\[\[:space:\]\]", guide.line = NULL, line.color = "black", guide.line.color = "red", guide.line.type = "dashed", plot.space = 0.1, plot.height = 0.2 ) ``` -------------------------------- ### Add GC content annotation with geom_gc Source: https://context7.com/showteeth/ggcoverage/llms.txt Appends a GC content line plot. Can use BSgenome objects or local FASTA files. A guide line can be explicitly set or defaults to the mean GC content. ```r if (requireNamespace("BSgenome.Hsapiens.UCSC.hg19", quietly = TRUE)) { library("BSgenome.Hsapiens.UCSC.hg19") bw_file <- system.file("extdata", "DNA-seq", "SRR054616.bw", package = "ggcoverage") dna_df <- LoadTrackFile(track.file = bw_file, format = "bw", region = "4:1-160000000") dna_df$seqnames <- paste0("chr", dna_df$seqnames) dna_coverage <- ggcoverage( data = dna_df, color = "grey", mark.region = NULL, range.position = "out" ) # GC annotation using BSgenome dna_coverage + geom_gc( bs.fa.seq = BSgenome.Hsapiens.UCSC.hg19, guide.line = 0.5, # explicit guide line at 50% GC line.color = "black", guide.line.color = "red", plot.height = 0.2 ) # GC annotation using a local FASTA file dna_coverage + geom_gc(fa.file = "/path/to/hg19.fa", guide.line = NULL) # NULL = use mean GC } ``` -------------------------------- ### Sequential normalization using LoadTrackFile Source: https://github.com/showteeth/ggcoverage/blob/main/docs/articles/TimeAndMemory.html Performs sequential normalization of BAM files using the LoadTrackFile function. This method is typically slower than parallel normalization. Requires sample metadata and specifies the track folder, format, normalization method, region, bamCoverage path, and extension. ```r # prepare sample metadata sample.meta = data.frame(SampleName=c('SRR054616_rep1','SRR054616_rep2','SRR054616_rep3'), Type = c("SRR054616_rep1","SRR054616_rep2","SRR054616_rep3"), Group = c("rep1", "rep2", "rep3")) sample.meta # track folder track.folder = "./test" # run system.time(track.df <- LoadTrackFile( track.folder = track.folder, format = "bam", norm.method = "RPKM", region = "14:21,677,306-21,737,601", bamcoverage.path = "~/anaconda3/bin/bamCoverage", extend = 2000, meta.info = sample.meta )) #> user system elapsed #> 1169.767 35.005 1208.704 ``` -------------------------------- ### Add Contact Map to Coverage Plot with geom_tad2 Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/geom_tad2.html This example demonstrates how to add a contact map to a ggcoverage plot. It requires loading the ggcoverage and HiCDataHumanIMR90 libraries, preparing a matrix and granges object, and then combining ggcoverage with geom_tad2. ```R library(ggcoverage) library(HiCDataHumanIMR90) data(Dixon2012_IMR90, package = "HiCDataHumanIMR90") mat <- as.matrix(hic_imr90_40@.Data[[1]]@intdata) # prepare coverage dataframe df <- data.frame( seqnames = "chr1", start = seq(from = 50000000, to = 59999000, by = 1000), end = seq(from = 50001000, to = 60000000, by = 1000), score = sample(1:100, 10000, replace = TRUE), Type = "Example", Group = "Example" ) # create plot ggcoverage(data = df, color = "grey", region = "chr1:50000000-56000000", mark.region = NULL, range.position = "out") + geom_tad2(matrix = log2(mat + 1), granges = granges, zlim = 5, color.palette = c("blue", "red")) ``` -------------------------------- ### ggcoverage() Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/index.html Creates a coverage plot. ```APIDOC ## ggcoverage() ### Description Create Coverage Plot. ### Function Signature ggcoverage() ``` -------------------------------- ### Add Peak Annotation to Coverage Plot Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/geom_peak.html This example demonstrates how to add peak annotations to a coverage plot. It requires loading track files and optionally GTF files for gene annotations. Ensure the necessary libraries are loaded. ```r # library(ggcoverage) # library(rtracklayer) # sample.meta <- data.frame( # SampleName = c("Chr18_MCF7_ER_1", "Chr18_MCF7_ER_2", "Chr18_MCF7_ER_3", "Chr18_MCF7_input"), # Type = c("MCF7_ER_1", "MCF7_ER_2", "MCF7_ER_3", "MCF7_input"), # Group = c("IP", "IP", "IP", "Input") # ) # track folder # track.folder <- system.file("extdata", "ChIP-seq", package = "ggcoverage") # load bigwig file # track.df <- LoadTrackFile( # track.folder = track.folder, format = "bw", # meta.info = sample.meta # ) # gtf.file <- system.file("extdata", "used_hg19.gtf", package = "ggcoverage") # gtf.gr <- rtracklayer::import.gff(con = gtf.file, format = "gtf") # create mark region # mark.region <- data.frame(start = c(76822533), end = c(76823743), label = c("Promoter")) # basic.coverage <- ggcoverage( # data = track.df, color = "auto", region = "chr18:76822285-76900000", # mark.region = mark.region, show.mark.label = FALSE # ) # get consensus peak file # peak.file <- system.file("extdata", "ChIP-seq", "consensus.peak", package = "ggcoverage") # basic.coverage + geom_gene(gtf.gr = gtf.gr) + geom_peak(bed.file = peak.file) ``` -------------------------------- ### Define Sample Metadata Source: https://github.com/showteeth/ggcoverage/blob/main/docs/articles/CustomizeThePlot.html Create a data frame containing metadata for sequencing samples, including sample names, types, and experimental groups. This is used to organize and label tracks. ```R # sample metadata sample.meta = data.frame(SampleName=c('Chr18_MCF7_ER_1','Chr18_MCF7_ER_2','Chr18_MCF7_ER_3','Chr18_MCF7_input'), Type = c("MCF7_ER_1","MCF7_ER_2","MCF7_ER_3","MCF7_input"), Group = c("IP", "IP", "IP", "Input")) sample.meta ``` -------------------------------- ### theme_protein() Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/theme_protein.html Applies a theme suitable for protein visualizations. ```APIDOC ## theme_protein() ### Description Applies a theme suitable for protein visualizations. ### Value List of layers. ``` -------------------------------- ### Add Protein Feature Annotations Source: https://github.com/showteeth/ggcoverage/blob/main/docs/articles/ggcoverage.html Adds custom annotations to a protein coverage plot based on protein features obtained from sources like UniProt. The features are defined in a data frame with ProteinID, start, end, and Type. ```R # protein feature obtained from UniProt protein.feature.df = data.frame(ProteinID = "sp|P02769|ALBU_BOVIN", start = c(1, 19, 25), end = c(18, 24, 607), Type = c("Signal", "Propeptide", "Chain")) # add annotation protein.coverage + geom_protein_feature(data = protein.feature.df) ``` -------------------------------- ### theme_base() Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/index.html Applies a base theme for geom_base. ```APIDOC ## theme_base() ### Description Theme for geom_base. ### Function Signature theme_base() ``` -------------------------------- ### Add Protein Feature Annotations Source: https://github.com/showteeth/ggcoverage/blob/main/README.md Adds custom annotations to the protein coverage plot. Features are defined in a dataframe with ProteinID, start, end, and Type. This is useful for highlighting specific regions like signal peptides or propeptides. ```r protein_feature_df <- data.frame( ProteinID = "sp|P02769|ALBU_BOVIN", start = c(1, 19, 25), end = c(18, 24, 607), Type = c("Signal", "Propeptide", "Chain") ) ``` -------------------------------- ### Create Mass Spectrometry Protein Coverage Plot with ggprotein Source: https://context7.com/showteeth/ggcoverage/llms.txt Builds a protein peptide coverage plot from Proteome Discoverer output and a reference FASTA file. Displays covered and uncovered regions with an optional summary table. Requires the openxlsx package. ```r if (requireNamespace("openxlsx", quietly = TRUE)) { library(openxlsx) coverage_file <- system.file("extdata", "Proteomics", "MS_BSA_coverage.xlsx", package = "ggcoverage") coverage_df <- read.xlsx(coverage_file, sheet = "Sheet1") fasta_file <- system.file("extdata", "Proteomics", "MS_BSA_coverage.fasta", package = "ggcoverage") protein_id <- "sp|P02769|ALBU_BOVIN" protein_coverage <- ggprotein( coverage.df = coverage_df, fasta.file = fasta_file, protein.id = protein_id, XCorr.threshold = 2, # minimum XCorr to keep a peptide confidence = "High", contaminant = NULL, # set TRUE to remove contaminant peptides color = "grey", mark.bare = TRUE, # highlight uncovered regions in red mark.color = "red", show.table = TRUE, # show coverage summary table table.position = "top_right", range.position = "out" ) protein_coverage } ``` -------------------------------- ### theme_tad() Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/index.html Applies a theme for geom_tad. ```APIDOC ## theme_tad() ### Description Theme for geom_tad. ### Function Signature theme_tad() ``` -------------------------------- ### Load Proteome Discoverer Coverage Data Source: https://github.com/showteeth/ggcoverage/blob/main/docs/index.html Reads coverage data from an Excel file exported from Proteome Discoverer. Ensure the 'openxlsx' package is installed. The `head()` function is used to display the first few rows of the loaded data frame. ```R library(openxlsx) # prepare coverage dataframe coverage.file <- system.file("extdata", "Proteomics", "MS_BSA_coverage.xlsx", package = "ggcoverage") coverage.df <- openxlsx::read.xlsx(coverage.file) # check the data head(coverage.df) ``` -------------------------------- ### Load Bigwig Track Files Source: https://github.com/showteeth/ggcoverage/blob/main/docs/index.html Loads bigwig files for specified regions, extending the region by a given amount. Requires metadata information for sample identification. ```R # track folder track.folder = system.file("extdata", "RNA-seq", package = "ggcoverage") # load bigwig file track.df = LoadTrackFile(track.folder = track.folder, format = "bw", region = "chr14:21,677,306-21,737,601", extend = 2000, meta.info = sample.meta) ``` -------------------------------- ### Add a Custom Peak Layer to a Plot Source: https://github.com/showteeth/ggcoverage/blob/main/docs/articles/CustomizeThePlot.html Create a new peak layer using pseudo-peak data. When using your own data, ensure it's used as a region constraint. This example demonstrates adding a red segment representing a peak. ```r # create pseudo-peak, you can load your peak file instead (be aware of 0-based/1-based) pseudo_peak = data.frame(chr="chr18", start = 76840533, end = 76842533) # get region constraint plot.region.start <- coverage.data[1, "start"] plot.region.end <- coverage.data[nrow(coverage.data), "end"] # create plot peak.plot = ggplot() + geom_segment( data = pseudo_peak, aes_string(x = "start", xend = "end", y = "1", yend = "1"), color = "red", size = 5 ) + labs(y="Peak") + theme_peak(margin.len = 0.1, x.range = c(plot.region.start, plot.region.end)) peak.plot ``` -------------------------------- ### Highlight Base Position with SNV Source: https://github.com/showteeth/ggcoverage/blob/main/README.md Creates a ggcoverage plot with base annotation, highlighting SNV positions using the 'highlight' type. Requires ggcoverage, BAM file, and BSgenome. ```r # highlight one base ggcoverage( data = track_df, color = "grey", range.position = "out", single.nuc = TRUE, rect.color = "white" ) + geom_base( bam.file = bam_file, bs.fa.seq = BSgenome.Hsapiens.UCSC.hg19, mark.type = "highlight" ) + geom_ideogram(genome = "hg19", plot.space = 0) ``` -------------------------------- ### Add Protein Features with geom_feature Source: https://context7.com/showteeth/ggcoverage/llms.txt Appends protein feature annotations (e.g., domains, signal peptides) to a protein coverage plot. Requires a dataframe with ProteinID, start, end, and Type columns. Features are colored distinctly based on type. ```r if (requireNamespace("openxlsx", quietly = TRUE)) { library(openxlsx) coverage_file <- system.file("extdata", "Proteomics", "MS_BSA_coverage.xlsx", package = "ggcoverage") fasta_file <- system.file("extdata", "Proteomics", "MS_BSA_coverage.fasta", package = "ggcoverage") protein_id <- "sp|P02769|ALBU_BOVIN" protein_coverage <- ggprotein( coverage.df = read.xlsx(coverage_file), fasta.file = fasta_file, protein.id = protein_id, range.position = "out" ) # Features obtained from UniProt annotation feature_df <- data.frame( ProteinID = protein_id, start = c(1, 19, 25), end = c(18, 24, 607), Type = c("Signal", "Propeptide", "Chain") ) protein_coverage + geom_feature( feature.df = feature_df, feature.color = c("#4d81be", "#173b5e", "#6a521d"), feature.size = 5, plot.height = 0.1 ) } ``` -------------------------------- ### LoadTrackFile() Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/index.html Loads track data from a file into a dataframe. ```APIDOC ## LoadTrackFile() ### Description Load Track File to Dataframe. ### Function Signature LoadTrackFile() ``` -------------------------------- ### Add Protein Feature Annotation Source: https://github.com/showteeth/ggcoverage/blob/main/docs/index.html Adds feature annotations to an existing protein coverage plot. The feature data frame should include protein ID, start and end positions, and feature type. Custom colors can be applied to different feature types. ```R # protein feature obtained from UniProt protein.feature.df = data.frame(ProteinID = "sp|P02769|ALBU_BOVIN", start = c(1, 19, 25), end = c(18, 24, 607), Type = c("Signal", "Propeptide", "Chain")) # add annotation protein.coverage + geom_feature(feature.df = protein.feature.df, feature.color = c("#4d81be","#173b5e","#6a521d")) ``` -------------------------------- ### Load Hi-C Link File Source: https://github.com/showteeth/ggcoverage/blob/main/README.md Specifies the file path for Hi-C link data in BEDPE format. ```r # prepare arcs link_file <- system.file("extdata", "HiC", "HiC_link.bedpe", package = "ggcoverage") ``` -------------------------------- ### Add Feature Annotation to Coverage Plot Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/geom_feature.html Use geom_feature to add custom feature annotations to a protein coverage plot. Specify features using a data frame with 'ProteinID', 'start', 'end', and 'Type' columns. Customize feature colors using a vector. ```R # library(ggcoverage) # coverage.file <- system.file("extdata", "Proteomics", "MS_BSA_coverage.xlsx", package = "ggcoverage") # fasta.file <- system.file("extdata", "Proteomics", "MS_BSA_coverage.fasta", package = "ggcoverage") # protein.id = "sp|P02769|ALBU_BOVIN" # protein.coverage = ggprotein(coverage.file = coverage.file, fasta.file = fasta.file, protein.id = protein.id) # feature.df = data.frame(ProteinID = protein.id, start = c(1, 19, 25), end = c(18, 24, 607), # Type = c("Signal", "Propeptide", "Chain")) # protein.coverage + # geom_feature(feature.df = feature.df, feature.color = c("#4d81be","#173b5e","#6a521d")) ``` -------------------------------- ### Create Basic Coverage Plot Source: https://github.com/showteeth/ggcoverage/blob/main/README.md Generates a basic coverage plot with GC and ideogram annotations. Requires BSgenome and GTF data. ```r basic_coverage + geom_gc(bs.fa.seq = BSgenome.Hsapiens.UCSC.hg19) + geom_gene(gtf.gr = gtf_gr) + geom_ideogram(genome = "hg19") ``` -------------------------------- ### Add Gene Annotation to Coverage Plot using geom_gene Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/geom_gene.html This example demonstrates how to add gene annotations to a basic coverage plot. It requires loading track data, importing a GTF file into a Granges object, creating a basic coverage plot, and then adding the geom_gene layer with the GTF data. ```R # library(ggcoverage) # library(utils) # library(rtracklayer) # meta.file <- system.file("extdata", "RNA-seq", "meta_info.csv", package = "ggcoverage") # sample.meta <- utils::read.csv(meta.file) # track folder # track.folder <- system.file("extdata", "RNA-seq", package = "ggcoverage") # load bigwig file # track.df <- LoadTrackFile( # track.folder = track.folder, format = "bw", # meta.info = sample.meta # ) # gtf.file <- system.file("extdata", "used_hg19.gtf", package = "ggcoverage") # gtf.gr <- rtracklayer::import.gff(con = gtf.file, format = "gtf") # basic.coverage <- ggcoverage(data = track.df, color = "auto", range.position = "out") # basic.coverage + geom_gene(gtf.gr = gtf.gr) ``` -------------------------------- ### theme_aa() Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/index.html Applies a theme for geom_base with amino acid display. ```APIDOC ## theme_aa() ### Description Theme for geom_base with Amino Acid. ### Function Signature theme_aa() ``` -------------------------------- ### ggprotein() Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/index.html Creates a mass spectrometry protein coverage plot. ```APIDOC ## ggprotein() ### Description Create Mass Spectrometry Protein Coverage Plot. ### Function Signature ggprotein() ``` -------------------------------- ### Create Facet View Coverage Plot Source: https://github.com/showteeth/ggcoverage/blob/main/docs/articles/ggcoverage.html Generates a basic facet view coverage plot. Requires 'track.df' data, 'mark.region', and 'range.position' to be set. ```R basic.coverage = ggcoverage(data = track.df, color = "auto", plot.type = "facet", mark.region = mark.region, range.position = "out") basic.coverage ``` -------------------------------- ### theme_coverage2() Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/index.html Applies a theme for geom_coverage. ```APIDOC ## theme_coverage2() ### Description Theme for geom_coverage. ### Function Signature theme_coverage2() ``` -------------------------------- ### Load Mass Spectrometry Protein Coverage Data Source: https://github.com/showteeth/ggcoverage/blob/main/README.md Load protein coverage data from an Excel file using the openxlsx package. This snippet prepares a dataframe for mass spectrometry analysis. ```r library(openxlsx) # prepare coverage dataframe coverage_file <- system.file("extdata", "Proteomics", "MS_BSA_coverage.xlsx", package = "ggcoverage" ) coverage_df <- openxlsx::read.xlsx(coverage_file, sheet = "Sheet1") ``` -------------------------------- ### Load and Inspect Coverage Data Source: https://github.com/showteeth/ggcoverage/blob/main/README.md Loads and displays the first few rows of the coverage_df dataframe to inspect its structure and content. ```r head(coverage_df) ``` -------------------------------- ### theme_coverage() Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/index.html Applies a theme for geom_coverage. ```APIDOC ## theme_coverage() ### Description Theme for geom_coverage. ### Function Signature theme_coverage() ``` -------------------------------- ### Prepare Protein Sequence Data Source: https://github.com/showteeth/ggcoverage/blob/main/README.md Reads a protein FASTA file into an AAStringSet object for use with ggcoverage. Ensure the FASTA file path is correct. ```r fasta_file <- system.file("extdata", "Proteomics", "MS_BSA_coverage.fasta", package = "ggcoverage") protein_set <- Biostrings::readAAStringSet(fasta_file) protein_set ``` -------------------------------- ### Load Hi-C Bin Data Source: https://github.com/showteeth/ggcoverage/blob/main/docs/index.html Loads Hi-C bin data from a tab-separated file and converts it into a GenomicRanges object. Column names are set for clarity. ```R ## bin hic.bin.file = system.file("extdata", "HiC", "HiC_bin.txt", package = "ggcoverage") hic.bin = read.table(file = hic.bin.file, sep = "\t") colnames(hic.bin) = c("chr", "start", "end") hic.bin.gr = GenomicRanges::makeGRangesFromDataFrame(df = hic.bin) ``` -------------------------------- ### Generate Basic Protein Coverage Plot Source: https://github.com/showteeth/ggcoverage/blob/main/docs/articles/ggcoverage.html Creates a basic protein coverage plot using ggprotein. Requires coverage and FASTA files, and a specific protein ID. The range.position argument controls how ranges are displayed. ```R protein.coverage = ggprotein(coverage.file = coverage.file, fasta.file = fasta.file, protein.id = "sp|P02769|ALBU_BOVIN", range.position = "out") protein.coverage ``` -------------------------------- ### theme_tad2() Source: https://github.com/showteeth/ggcoverage/blob/main/docs/reference/index.html Applies a theme for geom_tad2. ```APIDOC ## theme_tad2() ### Description Theme for geom_tad2. ### Function Signature theme_tad2() ``` -------------------------------- ### Prepare Mark Regions Source: https://github.com/showteeth/ggcoverage/blob/main/docs/articles/ggcoverage.html Create a data frame defining specific genomic regions to be marked or highlighted in subsequent visualizations. This is useful for annotating specific areas of interest. ```R # create mark region mark.region=data.frame(start=c(21678900,21732001,21737590), ``` -------------------------------- ### Create Basic Coverage Plot Source: https://github.com/showteeth/ggcoverage/blob/main/docs/articles/TimeAndMemory.html Generates a basic coverage plot from a pre-loaded track data frame. This operation is very fast. The resulting plot can be viewed more clearly when saved as a PDF. ```R # create basic coverage plot # the running time is very small system.time(basic.coverage <- ggcoverage(data = track.df, color = "red", range.position = "out", show.mark.label = FALSE)) ## 用户 系统 流逝 ## 0.048 0.001 0.048 ```