Hi,
I'm trying to reproduce the calculation of moderated z-score (MODZ) described in PMID: 29195078 for some microarray data. Calculation is described as follows:
Replicate-consensus signatures (MODZ) L1000 experiments are typically done in 3 or more biological replicates. We derive a consensus replicate signature by applying the moderated z-score (MODZ) procedure as follows. First, a pairwise Spearman correlation matrix is computed between the replicate signatures in the space of landmark genes with trivial self-correlations being ignored (set to 0). Then, weights for each replicate are computed as the sum of its correlations to the other replicates, normalized such that all weights sum to 1. Finally, the consensus signature is given by the linear combination of the replicate signatures with the coefficients set to the weights. This procedure serves to mitigate the effects of uncorrelated or outlier replicates, and can be thought of as a ‘de-noised’ representation of the given experiment’s transcriptional consequences.
I already calculated robust z-score for each gene (n=900) at every sample (n=6, 3 controls, 3 treatments) and I used the transposed matrix (genes as columns, samples as rows) to calculate pairwise spearman correlation using:
cor<- cor(tm, use="pairwise.complete.obs","spearman")
but I'm sure I'm missing something because I get error
Error in cor(tm, use = "pairwise.complete.obs", "spearman") :
'y' must be numeric
I don't know how to define x or y (I'm quite newby with R), but as I understand, I have to correlate control 1 to control 2, control 2 to control 3 and control 1 to control 3 individually and same for treatments and then compute the weights.
Any ideas about the code or how to proceed will be very much welcome!!!
Gema
You could try:
Your tm object should only contain numerical values. Most likely it is currently a data-frame object, which is not specifically numerical.
Wait, cross-post: C: correlation between genes
If you want pairwise sample correlations, then your samples should be columns, with genes as rows
yes it was me, but I wanted to post the whole thing to make things clear about what I need to do
I just get the same error with that code. The only way I found to skip that error and make the code work is to set y as tm, but I don't know the meaning of that
y<- tm cor<- cor(tm, y, use="pairwise.complete.obs","spearman")
Can you display a small version of tm (like first 10 genes)?
There is no issue setting y as tm. It just means that it will correlate tm to tm.
If you want gene-to-gene correlations, then:
If you want sample-to-sample correlations, then:
Sorry, I reached the limit of coments per 6h... this is an example matrix of my data, I have 6 different samples and 928 genes, it is already trasposed
https://imgur.com/a/iZtsm
what I need to get according to the description of the calculation, is a correlation value per gene in each sample, and the output from cor() is only one correlation value per gene pair, I'm not sure how to get that.
Actually, this is a bit weird because the weighted average of zscores isn´t a zscore.
Why did you post this as an answer?
I have moved it to a comment. If you provide an answer, please answer the question that was originally asked.
yes sorry it was just a thought I did not answer the question.
No problem - no need to worry at this point.