Comments (1)
I am not sure if this a solution you are after but you can use e.g. plot_grid()
to plot coverage above or below the ggtranscript
plot. I would just make sure to use the same x-axis ccordinates for both plots. Here is an example function to plot coverage from a bigwig:
TranscriptCoveragePlot <-
function(seqnames, start, end, strand, gene_id, gtf, coverage) {
# Filter long read gtf/gff for gene of interest
gtf_filtered <- gtf[gtf$gene_id == gene_id]
# loci used to filter data
locus_subset <- GRanges(seqnames = seqnames, ranges = IRanges(start = start, end = end), strand = strand)
# coverage data
coverage_data <- rtracklayer::import.bw(coverage) %>% subsetByOverlaps(., locus_subset) %>% as.data.frame()
# Plot transcripts
exons <- data.frame(gtf_filtered) %>% dplyr::filter(type == "exon")
introns <- exons %>% to_intron(group_var = "transcript_id")
CDS <- data.frame(gtf_filtered) %>% dplyr::filter(type == "CDS")
transcript_plot <-
exons %>%
ggplot(aes(
xstart = start,
xend = end,
y = transcript_id)) +
geom_range(fill = "white",
height = 0.25) +
geom_range(data = CDS) +
geom_intron(
data = introns,
arrow.min.intron.length = 500,
arrow = grid::arrow(ends = "first", length = grid::unit(0.1, "inches"))
) +
labs(y = "Transcript name", x = "") +
xlim(start(locus_subset), end(locus_subset))
# coverage data
coverage_plot <-
coverage_data %>%
ggplot(aes(
xmin = start,
xmax = end,
ymin = 0,
ymax = score
)) +
geom_rect(show.legend = F, alpha = 0.8) +
xlim(start(locus_subset), end(locus_subset))
# Final plot
transcript_coverage_plot <-
plot_grid(
transcript_plot,
coverage_plot,
ncol = 1,
align = "hv",
rel_heights = c(1, 3.5),
axis = "lr"
)
return(transcript_coverage_plot)}
from ggtranscript.
Related Issues (12)
- high-level workflow example HOT 1
- Warning about size being replaced by linewidth in ggplot2 3.4.0+
- reverse orientation of transcripts on minus strand HOT 1
- shortened gaps with exon and CDS
- extend `to_diff()` to junctions HOT 1
- labeling of exons (junctions?) HOT 4
- packing non-overlapping transcripts on the same y
- Allow `shorten_gaps()` to take into account CDS as well as exons
- Make plots interactive HOT 4
- Problems using facet_wrap HOT 2
- lines extend to gene model with geom_junction_label_repel HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ggtranscript.