Learn R Programming

RNAprobR (version 1.4.0)

bedgraph2norm: Import bedgraph to GRanges

Description

Function importing data from bedgraph format compatible with UCSC Genome Browser to norm_GR data frame. Warning: Compatible only with bedgraph files generated by norm2bedgraph function (bedgraph needs to have 2 tracks, first for plus strand, second for minus strand). May be used for transforming normalized data to another different annotation sets.

Usage

bedgraph2norm(bedgraph_file, fasta_file, txDb, bed_file, column_name = "bedgraph_score", add_to, track_strand = "+")

Arguments

bedgraph_file
path to compatible bedgraph file
fasta_file
path to fasta file which is used for a) choosing which transcripts to use (transcripts absent from fasta are not reported), b) providing sequence for to display in GRanges metadata
txDb
TranscriptDb object with transcript definitions. Names must match those in fasta_file
bed_file
character containing file path to BED file with transcript definitions. Supply txDb XOR bedfile
column_name
How to name imported metadata in GRanges
add_to
GRanges object made by other normalization function (dtcr(), slograt(), swinsor(), compdata()) to which values from bedgraph should be added.
track_strand
specifies which genomic strand the supplied bedgraph describes ("+" or "-"). Used only if the bedgraph file is composed of only one track.

Value

Function creates GRanges object or (if add_to specified) adds metadata to already existing object

See Also

norm2bedgraph, GR2norm_df, plotRNA, BED2txDb, dtcr, slograt, swinsor, compdata

Examples

Run this code
dummy_euc_GR_control <- GRanges(seqnames="DummyRNA",
IRanges(start=round(runif(100)*100), width=round(runif(100)*100+1)),
        strand="+", EUC=round(runif(100)*100))
dummy_euc_GR_treated <- GRanges(seqnames="DummyRNA",
                                IRanges(start=round(runif(100)*100),
                                        width=round(runif(100)*100+1)),
                                strand="+", EUC=round(runif(100)*100))
dummy_comp_GR_control <- comp(dummy_euc_GR_control)
dummy_comp_GR_treated <- comp(dummy_euc_GR_treated)
dummy_norm <- dtcr(control_GR=dummy_comp_GR_control,
                   treated_GR=dummy_comp_GR_treated)

write(strwrap("chr1\t134212702\t134229870\tDummyRNA\t0\t+
              \t134212806\t134228958\t0\t8\t347,121,24,152,66,120,133,1973,
              \t0,8827,10080,11571,12005,13832,14433,15195,", width = 300),
      file="dummy.bed")
norm2bedgraph(norm_GR = dummy_norm, bed_file = "dummy.bed")

write(c(">DummyRNA", paste(sample(c("A","C","G","T"), 100, replace=TRUE),
                           collapse="")), file="dummy.fa")
bedgraph2norm(bedgraph_file = "out_file.bedgraph", fasta_file = "dummy.fa",
              bed_file = "dummy.bed")

Run the code above in your browser using DataLab