Generate segment plot to visualize genomic regions related to reference regions.
Source:R/viz_related.R
plot_regions_relative_to_reference.Rd
Generate segment plot to visualize genomic regions related to reference regions.
Arguments
- query
an object of
GenomicRanges::granges()
to be visualized relative to reference- reference
an object of
GenomicRanges::granges()
against whichquery
regions should be mapped.
Examples
if (FALSE) {
ref_file <- system.file("extdata", "Homo_sapiens.GRCh38.101.gtf.gz" ,package = "parcutils")
ref_data <- rtracklayer::import(ref_file) %>%
tibble::as_tibble() %>%
dplyr::mutate(seqnames = stringr::str_c("chr",seqnames ,sep = "")) %>% plyranges::as_granges()
ref_data_gr <- ref_data %>%
dplyr::filter(type == "gene" & gene_biotype == "protein_coding")
query_regions_gr <- ref_data %>% dplyr::filter(type == "Selenocysteine") %>% sample(5000)
oo <- plot_regions_relative_to_reference(query = query_regions_gr, reference = ref_data_gr)
oo$plot
oo$data %>% ggplot2::ggplot(aes(x = q_relt_start)) + geom_density()
}