Given the output of fullCoverage, this function coerces the coverage to a GRanges object using coerceGR and then exports the coverage to a BigWig file using export.bw.

createBwSample(sample, path = ".", fullCov, keepGR = TRUE, ...)

Arguments

sample

The name or integer index of the sample of interest to coerce to a GRanges object.

path

The path where the BigWig file will be created.

fullCov

A list where each element is the result from loadCoverage used with returnCoverage = TRUE. Can be generated using fullCoverage.

keepGR

If TRUE, the GRanges object created by coerceGR is returned. Otherwise it is discarded.

...

Arguments passed to other methods and/or advanced arguments. Advanced arguments:

verbose

If TRUE basic status updates will be printed along the way.

Passed to coerceGR.

Value

Creates a BigWig file with the coverage information (regions with coverage greater than zero) for a given sample. If keepGR it returns the output from coerceGR.

See also

GRanges, export.bw, linkcoerceGR

Author

Leonardo Collado-Torres

Examples

## Create a small fullCov object with data only for chr21
fullCov <- list("chr21" = genomeDataRaw)

## Create a BigWig for the first sample in a test directory
dir.create("createBwSample-example")
bw <- createBwSample("ERR009101", "createBwSample-example",
    fullCov = fullCov, seqlengths = c("chr21" = 48129895)
)
#> 2024-12-13 15:13:11.472733 coerceGR: coercing sample ERR009101
#> 2024-12-13 15:13:11.494464 createBwSample: exporting bw for sample ERR009101

## Explore the output
bw
#> GRanges object with 16 ranges and 1 metadata column:
#>         seqnames            ranges strand |     score
#>            <Rle>         <IRanges>  <Rle> | <integer>
#>   chr21    chr21 47410303-47410336      * |         1
#>   chr21    chr21 47410687-47410688      * |         1
#>   chr21    chr21 47410699-47410734      * |         1
#>   chr21    chr21 47410951-47410955      * |         1
#>   chr21    chr21          47411924      * |         1
#>     ...      ...               ...    ... .       ...
#>   chr21    chr21 47415237-47415272      * |         1
#>   chr21    chr21 47415317-47415352      * |         1
#>   chr21    chr21 47417629-47417664      * |         1
#>   chr21    chr21 47417674-47417676      * |         1
#>   chr21    chr21 47418035-47418067      * |         1
#>   -------
#>   seqinfo: 1 sequence from an unspecified genome

## Exports a single sample to a BigWig file