Hi Guys,
I have a large matrix as shown below mymatrix
. I would like to know if there is any way I can get the result in the form of list or matrix for each position with only those nucleotides that have values( i.e ones without NA's) and in decreasing order. For example, I want to get the result in these format:
In the form of matrix:
pos 161111 T(17) C(1)
pos 99022222 G(24) A(3)
or in the form of list
pos 161111
T C
17 1
pos 99022222
G A
24 3
and so forth...Thank you.
mymatrix
pos A C G T N
1611111 NA 1 NA 17 NA
99022222 3 NA 24 NA NA
99092333 NA 5 NA 91 NA
233232333 2 22 NA NA NA
How large of a matrix are we talking here? An efficient solution might be needed if it is too large. Otherwise, this problem is relatively easy and I will answer it when you reply.
It's a fairly large matrix. Thank you!
What dimensions?
dim(mymatrix)
Right now my matrix is of 6023 by 8.
OK, that's not too bad. I will write a quick answer for it in a sec.
Thank you, I would really appreciate that!