Open LiNk-NY opened 2 years ago
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)
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.
Created on 2022-05-20 by the reprex package (v2.0.1)