Questions tagged [genomicranges]
72 questions
6
votes
4 answers
Find which column ranges overlap after grouping in R
I have a huge data frame that looks like this.
I want to group_by(chr), and then for each chr to find
Is any range1 (start1, end1), within the chr group, overlapping with any range2 (start2,end2)?
library(dplyr)
df1 <- tibble(chr=c(1,1,2,2),
…

LDT
- 2,856
- 2
- 15
- 32
4
votes
1 answer
Should as.data.table method for GRanges modify the original object by reference by default?
When using the as.data.table() function from the data.table package to create a data.table out of a GRanges object,
the default method is called (https://github.com/Rdatatable/data.table/blob/master/R/as.data.table.R#L8-L10).
This leads to the…

Alex
- 106
- 5
3
votes
1 answer
Error using makeGRangesFromDataFrame in an R workflow for ATAC-seq
New to R. Recently working through an ATAC-seq workshow in R.
In Section 5.1 of where I call the makeGRangesFromDataFrame function I get the following error -
> atac_esca.gr <- makeGRangesFromDataFrame(atac_esca,keep.extra.columns = T)
Error in…

Ethidium Bromide
- 33
- 5
3
votes
1 answer
Merging adjacent bins with same property in GenomicRanges object
Having segmented a genome into adjacent non-overlapping bins, e.g. by tileGenome, I have computed some property by some means for each bin (say either 1 or 2).
Now I want to merge adjacent with the same property.
An minimal example is illustrated…

Sebastian Müller
- 573
- 4
- 15
2
votes
3 answers
GRanges as column in base::data.frame
I would like to store a GenomicRanges::GRanges object from Bioconductor as a single column in a base R data.frame. The reason I'd like to have it in a base R data.frame is because I'd like to write some ggplot2 functions that exclusively work with…

teunbrand
- 33,645
- 4
- 37
- 63
2
votes
2 answers
R : Count unique element per interval
Let say I've a list of non-overlapping genomic intervals.
chr1 1 100
chr1 101 200
chr1 201 300
chr1 301 400
and a list of genomic positions linked to different samples as :
chr1 50 sampleA
chr1 60 sampleB
chr1 110…

Nicolas Rosewick
- 1,938
- 4
- 24
- 42
2
votes
2 answers
Get ranges for synonymous and non-synonymous nucleotide positions within a codon separately
I have GRanges object (coordinates of all gene exons); coding_pos defines what is the start position of a codon in a particular exon (1 means that first nucleotide in exon is also the first nt in a codon, and so on).
grTargetGene itself looks like…

lizaveta
- 353
- 1
- 13
2
votes
2 answers
Granges - (left) join
I have two Granges objects and I would like them to be merge in order to combine both GRanges even if the metadata are not existing in both objects.
> t
GRanges object with 2 ranges and 5 metadata columns:
seqnames ranges strand | …

Bratten
- 31
- 5
2
votes
1 answer
Simulate random positions from a list of intervals
I am trying to develop a function in R to output random positions in list of given intervals.
My intervals file (14,600 lines) is a tab delimited bed file (chromosome start end name) that looks like this:
1 4953 16204 1
1 16284 …

fugu
- 6,417
- 5
- 40
- 75
2
votes
2 answers
pythonic equivalent to reduce() in R GRanges - how to collapse ranged data?
In R (albeit longwinded):
Here is a test data.frame
df <- data.frame(
"CHR" = c(1,1,1,2,2),
"START" = c(100, 200, 300, 100, 400),
"STOP" = c(150,350,400,500,450)
)
First I make GRanges object:
gr <- GenomicRanges::GRanges(
seqnames =…

mbyvcm
- 141
- 2
- 12
2
votes
0 answers
setdiff with GenomicRanges: no method for coercing this S4 class to a vector
I'm using setdiff() with two GR objects and before updating R on my computer my code worked fine:…

Mariela Cortés López
- 21
- 2
1
vote
0 answers
S4Vectors::expand on granges rows based on multiple columns
I have a GRANGES object similar to below:
GRanges object with 3 ranges and 2 metadata columns:
seqnames ranges strand | txid txname
|
-
[1] chr1 1-3 + | 1 a
[2] …

plenty_of_code
- 11
- 1
1
vote
0 answers
Generate Random Permutations of Genomic Ranges using Nullranges (matchedranges or bootranges)
I want to generate 200 random genomicranges that are 200kbp long each that can occur anywhere in the genome. I was recommended to try using nullranges, but I haven't figured out how to specify only generating 200 ranges / iteration. I think it takes…

erman
- 11
- 1
1
vote
0 answers
Concatenate consecutive iranges coordinates with same metadata value
I have this granges object:
gr <- GRanges(
seqnames = c(rep("chr1", 3)),
IRanges(start = c(1, 10, 20), end = c(5, 15, 25)),
group = c("A", "A", "B")
)
I would like to concatenate the events that are the same group (f.ex A) joining the…

msevilla
- 11
- 1
1
vote
2 answers
Remove hits of overlapping ranges based on another column in R
I have a large data frame that looks like this.
I want to group_by seqnames and for each group, I want to check for overlapping ranges between the start and end.
If there is any overlapping range, then it should stay the row with the highest…

LDT
- 2,856
- 2
- 15
- 32