This is a test version of Biostars. For the public version, visit https://www.biostars.org.
use PCA to see the correlation between samples WT and MT

Hi,

Is the code right for to use pca show correlation of samples?
gene_tpm_matrix rownames are genes, colnames are samples (WT and MT)

prcomp(log2(gene_tpm_matrix+1), scale=T)

I'm not sure my code(use tpm do log and use scale, I see someone use score), however, so did a test, I use one sample we can call it sample_MT_1 * 10000 to get sample_new, then add sample_new as one line to gene_tpm_matrix, then do PCA, but sample_new point far away from sample_mt_1 point, I think they should overlap completely since they are linearly correlated and PCA which uses linear arithmetic.

What worries me most is the pca code is right or not, is anybody familiar with it?

Thanks!

rna-seq r next-gen

1 answer

I'm relatively certain you will have to transpose the matrix first, i.e. columns should represent genes:

prcomp( t (log2(matrix + 1)), scale = TRUE)

Exactly, I forgot to write this step here, so it is prcomp(t(log2(gene_tpm_matrix+1)), scale=T) now. Thanks!

Log in to answer this question.