I have a dataframe with 4 columns:
chromosome start end score and for each columns I have multiple rows, like this:
seqnames start end V5 1 chrI 1540683 1540683 6.33554 2 chrI 1838049 1838049 2.81938 3 chrI 2706245 2706245 4.10906
I want to trasform my dataframe in a GRanges object so I try with makeGRangesFromDataFrame
neuron_gr <- makeGRangesFromDataFrame(neuron_df, keep.extra.columns = TRUE)
but my neuron_gr don't have a IRange valid, is like this:
>neuron_gr
GRanges object with 176 ranges and 1 metadata column:
seqnames ranges strand | V5
<Rle> <IRanges> <Rle> | <numeric>
[1] chrI 1540683 * | 6.33554
[2] chrI 1838049 * | 2.81938
[3] chrI 2706245 * | 4.10906
I only have the start number and not the range in IRanges.
I also try with this command:
gr <- GRanges(seqnames=neuron_df$seqnames,
ranges = IRanges(neuron_df$start, end=neuron_df$end),
strand = Rle(strand(c(rep("*", length(neuron_df$strand))))),
Conc = neuron_df$V5)
but it dosen't work neither How I can solve this problem? Thank you
Yep, like here:
Note that if all your ranges are one-base, then you can coerce the GRanges object to a GPos object:
See
?GPos
for more information.I do it but the matrix is still empty
What does that mean, exactly? What is 'the matrix' in this context? What do you mean when you say 'I do it'. Do what? It's best to pretend that you are talking to people who know nothing about what you are doing, and you need to supply all necessary information for them to help you.