ExportFilesForGViz: ExportFilesForGViz Function (ModAnnot)

View source: R/ModAnnot.R

ExportFilesForGVizR Documentation

ExportFilesForGViz Function (ModAnnot)

Description

Export data as files that can be directly used with Gviz Package (making tracks + displaying). Except for gff3 format, all available format allows streaming while making and displaying tracks with Gviz package. Multiple objects can be exported at the same time. All arguments (except "dnastringsetGenome" argument) must have the same length.

Usage

ExportFilesForGViz(
  dnastringsetGenome,
  cFileNames,
  listObjects,
  cFileFormats,
  cBigwigParameters = rep(NA, length(cFileNames)),
  lBigwigParametersByStrand = rep(NA, length(cFileNames)),
  cBamXaParameters = rep(NA, length(cFileNames))
)

Arguments

dnastringsetGenome

A DNAStringSet object containing the sequence for each contig.

cFileNames

A character vector giving the names of the files to be exported.

listObjects

A list of objects to be exported. Required format of the objects is described in "cFileFormats" argument documentation.

cFileFormats

A character vector giving the format for each file to be exported. The following exportation formats are supported:

  • Fasta using DNAStrinSet object : for sequenceTracks (streaming)

  • Bam using GRanges-like object : for alignmentTracks (streaming) (only the positions of the ranges will be retrieved) or for dataTracks (streaming) (only coverage of provided ranges will be displayed) or for annotationTracks (streaming) (positions of the ranges will be retrieved with the names of each range (e.g. gene name))

  • bw (bigwig) using GRanges-like object : for dataTracks (streaming) (only the chosen numeric parameter will be retrieved for each range provided)

  • gff3 using GRanges-like object : for annotationTracks or geneRegionTracks (not in streaming: more memory required for displaying)

cBigwigParameters

A character vector describing the name of the parameter to be stored in bigwig files. Must correspond to the name of a column in the provided Granges object. Use NA as value in the vector if the associated file is not to be exported as a bigwig. Defaults to "rep(NA, length(cFileNames)))"

lBigwigParametersByStrand

A logical vector: if TRUE, the bigwig parameter will be negative for each range that is located on the reverse strand in the GRanges object provided. Use NA as value in the vector if the associated file is not to be exported as a bigwig. Defaults to "rep(NA, length(cFileNames)))"

cBamXaParameters

A character vector describing a parameter to be stored as a "Xa" optional field in the exported bam file. Use NA as value in the vector if the associated file is not to be exported as a bam. If the exported file is a bam and if the value is NA or NULL, the bam will be exported without the "Xa" optional field. Defaults to "rep(NA, length(cFileNames)))"

Examples

# loading genome
myGenome <- Biostrings::readDNAStringSet(system.file(
  package = "DNAModAnnot", "extdata",
  "ptetraurelia_mac_51_sca171819.fa"
))

# Preparing a grangesPacBioCSV dataset
myGposPacBioCSV <-
  ImportPacBioCSV(
    cPacBioCSVPath = system.file(
      package = "DNAModAnnot", "extdata",
      "ptetraurelia.bases.sca171819.csv"
    ),
    cSelectColumnsToExtract = c(
      "refName", "tpl", "strand", "base",
      "score", "ipdRatio", "coverage"
    ),
    lKeepExtraColumnsInGPos = TRUE, lSortGPos = TRUE,
    cContigToBeAnalyzed = names(myGenome)
  )

## NOT RUN!
## Export files for Gviz
# ExportFilesForGViz(dnastringsetGenome = myGenome,
#                   cFileNames = c("ipdRatio_for_each_A.bw",
#                                  "score_for_all_bases.bw",
#                                  "newFastaOnlyscaffold51_17.fa"),
#                   listGRangesObjects = c(myGposPacBioCSV[myGposPacBioCSV$base == "A"],
#                                          myGposPacBioCSV,
#                                          myGenome["scaffold51_17"]),
#                   cFileFormats = c("bw", "bw", "fa"),
#                   cBigwigParameters = c("ipdRatio", "score", NA),
#                   lBigwigParametersByStrand = c(TRUE, TRUE, NA),
#                   cBamXaParameters = c(NA, NA, NA))

# loading annotation
library(rtracklayer)
myAnnotations <- readGFFAsGRanges(system.file(
  package = "DNAModAnnot", "extdata",
  "ptetraurelia_mac_51_annotation_v2.0_sca171819.gff3"
))

## NOT RUN!
## Export files for Gviz
# ExportFilesForGViz(dnastringsetGenome = myGenome,
#                   cFileNames = c("genes.bam"),
#                   listGRangesObjects = list(myAnnotations[myAnnotations$type == "gene"]),
#                   cFileFormats = c("bam"),
#                   cBamXaParameters = c("Name") )

AlexisHardy/DNAModAnnot documentation built on Feb. 27, 2023, 12:03 a.m.