GetModBaseCountsByFeature: GetModBaseCountsByFeature Function (ModAnnot)

View source: R/ModAnnot.R

GetModBaseCountsByFeatureR Documentation

GetModBaseCountsByFeature Function (ModAnnot)

Description

Return the Annotation provided with the counts (and counts per KiloBase pairs (kbp)) of the base modified (Mod) and the base letter of the modified base (Base). Example: for Mod="6mA", Base="A"; for Mod="5mC", Base="C".

Usage

GetModBaseCountsByFeature(
  grangesAnnotations,
  grangesModPos,
  gposModTargetBasePos,
  lIgnoreStrand = FALSE
)

Arguments

grangesAnnotations

A GRanges object containing the annotation for the genome assembly corresponding to the grangesModPos and gposModTargetBasePos provided. The Genomic features categories must be in a column named "type".

grangesModPos

A GRanges object containing Modifications Positions data to be counted.

gposModTargetBasePos

A GRanges or GPos object containing Base Positions (which can be targeted by the modification) to be counted.

lIgnoreStrand

If TRUE, Mod and Base will be counted independently of the strand of each feature. If FALSE, only Mod and Base on the same strand as the feature will be counted. Defaults to FALSE.

Value

A GRanges object based on grangesAnnotations with the counts:

  • Modcount: The number of "Mod" within this feature.

  • Modcount_perkbp: (The number of "Mod" within this feature divided by the size of the feature)*1000.

  • Basecount: The number of "Base" within this feature.

  • Basecount_perkbp: (The number of "Base" within this feature divided by the size of the feature)*1000.

Examples

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

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

# Preparing a grangesPacBioGFF and a grangesPacBioCSV datasets
myGrangesPacBioGFF <-
  ImportPacBioGFF(
    cPacBioGFFPath = system.file(
      package = "DNAModAnnot", "extdata",
      "ptetraurelia.modifications.sca171819.gff"
    ),
    cNameModToExtract = "m6A",
    cModNameInOutput = "6mA",
    cContigToBeAnalyzed = names(myGenome)
  )
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)
  )

# Retrieve annotations with "Mod" and "Base" counts (and counts per kbp)
myAnn_ModBase_counts <- GetModBaseCountsByFeature(
  grangesAnnotations = myAnnotations,
  grangesModPos = myGrangesPacBioGFF,
  gposModTargetBasePos = myGposPacBioCSV
)
myAnn_ModBase_counts

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