Closed oseias-r-junior closed 4 years ago
It sounds like there's something weird about the structure of your input matrix. Is it two dimensional? Maybe you need to flatten it first if it's a list of pairwise distances for six objects (= 15 distances)?
Thanks jwcarr for answering me.
I'll try to explain a little bit what I've tried to do...
Let's use your own basic example:
dists1 = [0.2, 0.4, 0.3, 0.6, 0.9, 0.4, 0.2, 0.4, 0.3, 0.6, 0.9] # in my case are proteomic dist (in this example are your data typed 2x) dists2 = [0.3, 0.3, 0.2, 0.7, 0.8, 0.3, 0.3, 0.3, 0.2, 0.7, 0.8] # in my case are transcriptomic dist (same as above)
Mantel.test(dists1, dists2, perms=10000, method='pearson', tail='upper')
ValueError Traceback (most recent call last)
Ah, I see... the first of your two examples is not valid because it contains 11 numbers, whereas the second example is valid because it contains 10 numbers. A list of pairwise distances can only have certain sizes. For example, let's say we know the locations of some cities and we measure the distance between each pair of cities:
As you can see, 11 pairwise distances is not possible.
Does that make sense?
Thanks for your kind reply and patience jwcarr! Yeah, now it does make sense.
I need to figure it out now how to iterate through my data to generate this N 'genes': (N^2 - N) / 2 distances. But this is another story...
Thank you again!
P.S. Tip for doing the iteration. Assuming you have five "genes", the following code will allow you to calculate the ten possible distances:
distances = []
for i in range(5):
for j in range(i+1, 5):
dist = calculate_distance_somehow(gene[i], gene[j])
distances.append(dist)
Is there any alternative in the case one have two distances lists with more than 10 items on each (15x1 matrix, e.g.)? Right now keeps getting that X is not a valid matrix...