### Create RaggedExperiment from GRangesList Source: https://github.com/sa-lee/superintronic/wiki/Design-Doc Converts a list of CompressedGRanges to a RaggedExperiment object. This is useful for representing coverage data in a matrix form for downstream analysis. ```r library(RaggedExperiment) x <- as(lapply(design$bam, compute_coverage), "CompressedGRangesList") wide <- RaggedExperiment(x, colData = design) ``` -------------------------------- ### Summarise Coverage in RaggedExperiment Source: https://github.com/sa-lee/superintronic/wiki/Design-Doc Summarises coverage over specified features within a RaggedExperiment object. This function is equivalent to the rangle-join-rangle strategy. ```r qreduceSummarizedExperiment(wide, features, fun_to_summarise_cov) ``` -------------------------------- ### Load Libraries and Collect Gene Parts Source: https://github.com/sa-lee/superintronic/blob/master/README.md Loads necessary libraries and collects intronic/exonic regions for a specific gene from a GTF file using plyranges. ```r library(superintronic) #> Warning: replacing previous import 'IRanges::slice' by 'plyranges::slice' when #> loading 'superintronic' suppressPackageStartupMessages(library(plyranges)) features <- system.file("extdata", "Homo_sapiens.GRCh37.75_subset.gtf", package = "airway") %>% collect_parts() %>% filter(gene_name == "SRM") features #> GRanges object with 1 range and 9 metadata columns: #> seqnames ranges strand | gene_id gene_name #> | #> [1] 1 11114641-11120081 - | ENSG00000116649 SRM #> gene_source gene_biotype type source n_olaps #> #> [1] ensembl_havana protein_coding gene protein_coding 1 #> exonic_parts #> #> [1] 1:11114641-11115261:-,1:11115838-11115983:-,1:11116068-11116151:-,... #> intronic_parts #> #> [1] 1:11115262-11115837:-,1:11115984-11116067:-,1:11116152-11116660:-,... #> ------- ``` -------------------------------- ### Compute Coverage from BAM Files Source: https://github.com/sa-lee/superintronic/blob/master/README.md Computes coverage scores from BAM files using a design data frame. Ensure the design data frame includes a column with paths to BAM files. The function can propagate metadata from the design to the resulting GRanges object. ```r design <- read.csv(system.file("extdata", "sample_table.csv", package = "airway")) %>% dplyr::select(sample_id = X, cell, dex, albut) %>% dplyr::mutate(bam = dir(system.file("extdata", package = "airway"), pattern = "*.bam", full.names = TRUE) ) cvg <- compute_coverage_long(design, source = "bam") cvg ``` -------------------------------- ### Combine Coverage and Gene Tracks Source: https://github.com/sa-lee/superintronic/blob/master/README.md Combines the coverage plot and the gene track plot into a single figure using the `patchwork` library. This provides a comprehensive view of coverage in relation to gene structure. ```r p / gene_track ``` -------------------------------- ### Facet Coverage by Cell Type Source: https://github.com/sa-lee/superintronic/blob/master/README.md Visualizes coverage scores faceted by a specific variable, such as 'cell' type. This allows for comparison of coverage across different experimental conditions. Requires `patchwork` for layout adjustments. ```r p <- cvg_over_features %>% mutate(strand = feature_strand) %>% view_coverage(score = score, colour = feature_type, facets = vars(cell)) + scale_color_brewer(palette = "Dark2") + guides(colour = FALSE) + labs(title = "Coverage over SRM") p / gene_track + patchwork::plot_layout(heights = c(3, 1)) ``` -------------------------------- ### Create Gene Body Track Source: https://github.com/sa-lee/superintronic/blob/master/README.md Generates a track plot representing gene segments. This function is useful for overlaying gene structures onto coverage plots. Requires the `features` data. ```r gene_track <- view_segments(unnest_parts(features), colour = feature_type) gene_track ``` -------------------------------- ### Visualize Coverage Over a Gene Source: https://github.com/sa-lee/superintronic/blob/master/README.md Generates a ggplot object for coverage over a genomic region. Requires the `ggplot2` library and `cvg_over_features` data. The coverage is aligned from 5' to 3' by default. ```r library(ggplot2) p <- cvg_over_features %>% mutate(strand = feature_strand) %>% view_coverage(score = score, colour = feature_type) + scale_color_brewer(palette = "Dark2") + guides(colour = FALSE) + labs(title = "Coverage over SRM") p ``` -------------------------------- ### Filter BAM Reads by Overlap and Extract Sequence Source: https://github.com/sa-lee/superintronic/wiki/Design-Doc Filters reads from a BAM file that overlap with a given feature and extracts the sequence. It then mutates the sequence to count occurrences of polyA strings and their positions. ```r read_bam("bam.bam") %>% filter_by_overlaps(feature) %>% select(seq) %>% mutate(a_runs = Biostrings::vcountPattern("AAAAA", seq), a_runs_inx = Biostrings::vmatchPattern("AAAAA", seq) ) ``` -------------------------------- ### Intersect Coverage with Genomic Features Source: https://github.com/sa-lee/superintronic/blob/master/README.md Intersects computed coverage GRanges with genomic features. This is useful for analyzing coverage specifically within gene parts or other defined regions. Ensure the 'features' object is properly defined. ```r cvg_over_features <- cvg %>% select(-bam) %>% join_parts(features) cvg_over_features ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.