Closed jantusan closed 2 years ago
Sorry, I just realised I was using an GRanges object that was actually unnamed...
It turns out to be trivial to filter by name the matrix, I leave the code below for future reference
If your GRanges is named, like this:
> genes_100
GRanges object with 100 ranges and 2 metadata columns:
seqnames ranges strand | ID symbol
<Rle> <IRanges> <Rle> | <character> <character>
AT1G01010 Chr1 3631-5899 + | AT1G01010 NAC001
AT1G01020 Chr1 6788-9130 - | AT1G01020 ARV1
AT1G03987 Chr1 11101-11372 + | AT1G03987 <NA>
AT1G01030 Chr1 11649-13714 - | AT1G01030 NGA3
AT1G01040 Chr1 23121-31227 + | AT1G01040 DCL1
... ... ... ... . ... ...
AT1G01725 Chr1 269792-270859 - | AT1G01725 <NA>
AT1G04047 Chr1 270067-270517 + | AT1G04047 <NA>
AT1G01730 Chr1 270797-272189 + | AT1G01730 <NA>
AT1G01740 Chr1 272111-274930 - | AT1G01740 BSK4
AT1G01750 Chr1 275188-276310 + | AT1G01750 ADF11
-------
seqinfo: 7 sequences from an unspecified genome; no seqlengths
and you made a matrix with normalizeToMatrix()
like that:
> mat
Normalize signal to target:
Upstream 2000 bp (50 windows)
Downstream 2000 bp (50 windows)
Include target regions (50 windows)
100 target regions
you can filter it like a normal matrix
>mat[c("AT1G01010", "AT1G01020", "AT1G03987"),]
Normalize signal to target:
Upstream 2000 bp (50 windows)
Downstream 2000 bp (50 windows)
Include target regions (50 windows)
3 target regions
Sure! I will support it. That is a nice suggestion!
Ah. I think it is already supported.
Yes, it is already supported, I was just doing it wrong 😅.
My case use it to make matrices for a lot of epigenetic marks for all the genes in the genome, and then be able to subset from that instead of making the matrices from scratch. I know you can subset by index but I always fear I will mess up the order of something in my objects and get it wrong, so I prefer names.
Yes, that is a safer solution :)
Thank you for the useful package!
I wonder if there is a way to filter a normalizedMatrix object by the names of the ranges that were used to make it.
In my case I have a GRanges object with named ranges that looks like this
but after computing the matrix, the names seem to be lost
Are the names there somewhere? or I should name them again in case I want to filter by the names?
Thanks in advance!