promote_common_mcols | R Documentation |
Given a GRangesList whose underlying ranges have mcols, this finds mcols of the ranges that are constant within each gene and promotes them to mcols of the GRangesList. For example, you have a GRangesList of exons grouped by gene, and the exons are annotated with gene IDs, then the gene ID column will be promoted to the GRangesList object itself.
promote_common_mcols( grl, delete_from_source = FALSE, blacklist = c("type", "Parent") )
grl |
A GRangesList |
delete_from_source |
If TRUE, delete any promoted mcols from the underlying GRanges, so that the GRangesList and underlying GRanges will not have any mcols in common (unless they already had some before). |
blacklist |
A vector of column names that should never be promoted. The default is to never promote "type" or "Parent", which is appropriate for typical GFF files. |
The same GRangesList, possibly with additional mcols derived from the underlying GRanges.
Note that if the GRangesList's mcols already contain some of the same colnames as the mcols of the inner GRanges, these will be replaced by the promoted mcols.
library(GenomicRanges) gr <- GRanges("chr1", IRanges(start = (1:10) * 100, width = 50), GeneID = rep(c("geneA", "geneB"), each=5), GeneName = rep(c("Gene A", "Gene B"), each=5), ExonID = rep(1:5, 2)) grl <- split(gr, gr$GeneID) # All the mcols are still in the underlying GRanges, with none in # the GRangesList. names(mcols(grl)) names(mcols(unlist(grl))) grl <- promote_common_mcols(grl) # Now grl has received the common mcols names(mcols(grl)) names(mcols(unlist(grl))) grl <- promote_common_mcols(grl, delete_from_source = TRUE) # Now grl and only grl has the common mcols names(mcols(grl)) names(mcols(unlist(grl)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.