kauralasoo / wiggleplotr

A small R package to make sequencing read coverage plots in R.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow region_coords in plotCoverage while rescale_introns = TRUE

whtns opened this issue · comments

This is a great package. I'm using in a shiny app. I'd like to plot a specific sub-genomic region while rescaling introns. I could do this with ggplot xlim (I think) but I'd also like to extract the coverage data and return to the user.

# set up code
require("dplyr")
require("GenomicRanges")
sample_data = dplyr::data_frame(sample_id = c("aipt_A", "aipt_C", "bima_A", "bima_C"), 
                                condition = factor(c("Naive", "LPS", "Naive", "LPS"), levels = c("Naive", "LPS")), 
                                scaling_factor = 1) %>%
  dplyr::mutate(bigWig = system.file("extdata",  paste0(sample_id, ".str2.bw"), package = "wiggleplotr"))

track_data = dplyr::mutate(sample_data, track_id = condition, colour_group = condition)

selected_transcripts = c("ENST00000438495", "ENST00000392477") #Plot only two transcripts of the gens

# This works 
plotCoverage(ncoa7_exons[selected_transcripts], ncoa7_cdss[selected_transcripts], 
             ncoa7_metadata, track_data, 
             heights = c(2,1), fill_palette = getGenotypePalette(),
             rescale_introns = FALSE,
             region_coords = c(125900000, 125950000)
             )

# This does not work
plotCoverage(ncoa7_exons[selected_transcripts], ncoa7_cdss[selected_transcripts], 
             ncoa7_metadata, track_data, 
             heights = c(2,1), fill_palette = getGenotypePalette(),
             # rescale_introns = FALSE,
             region_coords = c(2000, 4000)
)