Sorry for the follow-up question about this but, just looked at the diffExpr.P_C.matrix.R code and it looks like it did use the centered data for the Pearson correlations too? Or am I misreading something? See below for snippet and attached for the code:
initial_matrix = data # store before doing various data transformations
data = log2(data+1)
sample_factoring = colnames(data)
for (i in 1:nsamples) {
sample_type = sample_types[i]
replicates_want = sample_type_list[[sample_type]]
sample_factoring[ colnames(data) %in% replicates_want ] = sample_type
}
sampleAnnotations = matrix(ncol=ncol(data),nrow=nsamples)
for (i in 1:nsamples) {
sampleAnnotations[i,] = colnames(data) %in% sample_type_list[[sample_types[i]]]
}
sampleAnnotations = apply(sampleAnnotations, 1:2, function(x) as.logical(x))
sampleAnnotations = sample_matrix_to_color_assignments(sampleAnnotations, col=sample_colors)
rownames(sampleAnnotations) = as.vector(sample_types)
colnames(sampleAnnotations) = colnames(data)
data = as.matrix(data) # convert to matrix
# Centering rows
data = t(scale(t(data), scale=F))
write.table(data, file="diffExpr.P0.001_C2.matrix.log2.centered.dat", quote=F, sep=' ');
if (nrow(data) < 2) { stop("
**** Sorry, at least two rows are required for this matrix.
");}
if (ncol(data) < 2) { stop("
**** Sorry, at least two columns are required for this matrix.
");}
sample_cor = cor(data, method='pearson', use='pairwise.complete.obs')
write.table(sample_cor, file="diffExpr.P0.001_C2.matrix.log2.centered.sample_cor.dat", quote=F, sep=' ')
sample_dist = dist(t(data), method='euclidean')
hc_samples = hclust(sample_dist, method='complete')
pdf("diffExpr.P0.001_C2.matrix.log2.centered.sample_cor_matrix.pdf")
sample_cor_for_plot = sample_cor
if (is.null(hc_samples)) { RowV=NULL; ColV=NULL} else { RowV=as.dendrogram(hc_samples); ColV=RowV }
heatmap.3(sample_cor_for_plot, dendrogram='both', Rowv=RowV, Colv=ColV, col = myheatcol, scale='none', symm=TRUE, key=TRUE,
density.info='none', trace='none', symkey=FALSE, symbreaks=F, margins=c(10,10), cexCol=1, cexRow=1, cex.main=0.75, main=paste("sample correlation matrix
", "diffExpr.P0.001_C2.matrix.log2.centered") )
dev.off()
gene_cor = NULL