get_usage4plot {InPAS}R Documentation

prepare coverage data and fitting data for plot

Description

prepare coverage data and fitting data for plot

Usage

get_usage4plot(gr, proximalSites, sqlite_db, hugeData)

Arguments

gr

an object of GenomicRanges::GRanges

proximalSites

An integer(n) vector, specifying the coordinates of proximal CP sites. Each of the proximal sites must match one entry in the GRanges object, gr.

sqlite_db

A path to the SQLite database for InPAS, i.e. the output of setup_sqlitedb().

hugeData

A logical(1), indicating whether it is huge data

Value

An object of GenomicRanges::GRanges with metadata:

dat

A data.frame, first column is the position, the other columns are Coverage and value

offset

offset from the start of 3' UTR

Author(s)

Jianhong Ou, Haibo Liu

Examples

   library(BSgenome.Mmusculus.UCSC.mm10)
   library(TxDb.Mmusculus.UCSC.mm10.knownGene)
   genome <- BSgenome.Mmusculus.UCSC.mm10
   TxDb <- TxDb.Mmusculus.UCSC.mm10.knownGene

   ## load UTR3 annotation and convert it into a GRangesList
   data(utr3.mm10)
   utr3 <- split(utr3.mm10, seqnames(utr3.mm10))
   
   bedgraphs <- system.file("extdata",c("Baf3.extract.bedgraph",
                                        "UM15.extract.bedgraph"), 
                           package = "InPAS")
   tags <- c("Baf3", "UM15")
   metadata <- data.frame(tag = tags, 
                          condition = c("baf", "UM15"),
                          bedgraph_file = bedgraphs)
   outdir = tempdir()
   write.table(metadata, file =file.path(outdir, "metadata.txt"), 
               sep = "\t", quote = FALSE, row.names = FALSE)
   
   sqlite_db <- setup_sqlitedb(metadata = file.path(outdir, 
                                                    "metadata.txt"),
                               outdir)
   coverage <- list()
   for (i in seq_along(bedgraphs)){
   coverage[[tags[i]]] <- get_ssRleCov(bedgraph = bedgraphs[i],
                            tag = tags[i],
                            genome = genome,
                            sqlite_db = sqlite_db,
                            outdir = outdir,
                            removeScaffolds = TRUE,
                            BPPARAM = NULL)
   }
   coverage_files <- assemble_allCov(sqlite_db, 
                                     outdir, 
                                     genome, 
                                     removeScaffolds = TRUE)
                                     
   data4CPsSearch <- setup_CPsSearch(sqlite_db,
                                     genome,
                                     utr3,
                                     background = "10K",
                                     TxDb = TxDb,
                                     removeScaffolds = TRUE,
                                     BPPARAM = NULL,
                                     hugeData = TRUE,
                                     outdir = outdir)
                                     
   gr <- GRanges("chr6", IRanges(128846245, 128850081), strand = "-")
   names(gr) <- "chr6:128846245-128850081"
   data4plot <- get_usage4plot(gr,
                               proximalSites = 128849148, 
                               sqlite_db,
                               hugeData = TRUE)
   plot_utr3Usage(usage_data = data4plot, 
                  vline_color = "purple", 
                  vline_type = "dashed")

[Package InPAS version 2.2.0 Index]