Closed gtrichard closed 5 years ago
This ~is~ was intentional. If you read the documentation, you'll see that if you don't specify fill
, inflate()
will create a sparse logical matrix indicating which areas of the interaction space were present in x
. After all, if you don't tell inflate()
to fill
the matrix with something, then all it has is present/absent information for the pairwise interactions, so the only thing it can really do is to create a logical matrix.
I have since modified the code so that even when fill=
is not supplied, the function will still respect swap=
and sparse=
. In your case, it will return a non-sparse matrix of logicals. However, if you want to fill the matrix with contact values (intensities, read pairs, whatever), you have to tell inflate
where these values are.
If you were supplying an InteractionSet
object, inflate()
would automatically take the fill values from the first sample of the first assay, under the assumption that the assay contains some kind of interaction intensity. But with GInteractions
inputs, the values could be anywhere, so the user has to supply it.
Ah ok I got now thanks 👍
By using:
submatrix<-inflate(control.gi, regions.gr[[1]], regions.gr[[1]], swap=TRUE, sparse=FALSE, fill=control.gi@elementMetadata$norm.freq)
It worked, thanks!
Or just control.gi$norm.freq
should work. Avoid using @
if you can.
Dear @LTLA ,
I am trying to extract submatrices centered around a given set of regions.
For this purpose I am using inflate:
submatrix<-inflate(control.gi, regions.gr[[1]], regions.gr[[1]], swap=TRUE, sparse=FALSE)
regions.gr
is a list of GRanges, each one containing the bins that I want to use to make submatrices, which here consist in 81 consecutive bins of fixed size (in order to generate 81 by 81 matrices, I would like 0 for missing contacts).But despite
sparse=FALSE
as.matrix(submatrix) returns:81 x 81 sparse Matrix of class "lgCMatrix"
And an example first line:
Is there a way to output the actual contact values stored in the
control.gi
object for these submatrices?Thank you, Gautier