So the lecture i have made no comment on how to make a distance matrix like the one in the picture, and any online help seems to also gloss over this matrix build
Is it simply impossible? or so easy there exits no notes for it
Thanks in advance
Hey so if you have a gene expression matrix with genes as your row names and cells/samples as your columns, then you can do the following within R:
matdf <- as.matrix(df)
transposed.matdf <- t(matdf)
matdf.cor <- cor(transposed.matdf, y = NULL, use = "pairwise.complete.obs", method = c("pearson"))
df.dist.mat <- as.dist(1 - matdf.cor)
and then you probably know this to see the top 5 lines of the head of the matrix do:
Here's what helped me when I was doing this to make gene-gene correlation matrix for gene clustering:
Hope this helps!
Hej I really appreciate the help, but the biggest issue is not the methodical coding in of itself. But the creation of the gene by gene distance matric in my picture, at the bottom.
It's for note taking, and for some reason I cannot make a matrix like the one in the picture, without resulting to hard coding.
Is there anyway to make a matrix containing the subtracted value between each possible combination of 3 genes containing 3 velues?
gene 1 = 2
gene 2 = 3
gene 3 = 6
You subtract the column value with the row value, and then take the absolute value of the resulting number.
What is distance?
"Distance is the absolute value of the difference between the two points." Source: flexbooks.ck12.org
when a number or expression is surrounded by | it means take the absolute value of it
gene1 by gene1 = |2 - 2| = 0
gene 2 by gene 1 = |3-2| = 1
gene 1 by gene 2 = |2-3| = |-1| = 1
Please let me know if this clicks. If you need more help I could draw it out for you.
Login before adding your answer.
Use of this site constitutes acceptance of our User Agreement and Privacy