Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Representing missing ranges #66

Open
LiNk-NY opened this issue May 20, 2022 · 0 comments
Open

Representing missing ranges #66

LiNk-NY opened this issue May 20, 2022 · 0 comments

Comments

@LiNk-NY
Copy link
Contributor

LiNk-NY commented May 20, 2022

Given a character vector, how do we represent missing ranges?
This is an ugly hack but it preserves the length of the original input.
But I would not expect to get much mileage out of it.

suppressPackageStartupMessages(library(GenomicRanges))
cranges <- c("chr1:29553-30267", "chr1:36080-36081", "chr1:65418-69055", 
    "chr1:120931-133723", NA)
cranges[is.na(cranges)] <- "NA_character_:0"
as(cranges, "GRanges")
#> GRanges object with 5 ranges and 0 metadata columns:
#>            seqnames        ranges strand
#>               <Rle>     <IRanges>  <Rle>
#>   [1]          chr1   29553-30267      *
#>   [2]          chr1   36080-36081      *
#>   [3]          chr1   65418-69055      *
#>   [4]          chr1 120931-133723      *
#>   [5] NA_character_             0      *
#>   -------
#>   seqinfo: 2 sequences from an unspecified genome; no seqlengths

Created on 2022-05-20 by the reprex package (v2.0.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant