Skip to content

Commit

Permalink
bug correction:
Browse files Browse the repository at this point in the history
clustering in spearmann correlation was using euclidean distance.
improvement:
correlation coef is plotted instead of 1-coef
  • Loading branch information
lldelisle committed Oct 15, 2020
1 parent ff034cc commit ee823c9
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 38 deletions.
Binary file modified example/CorrelationMatrix_SpearWard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 42 additions & 38 deletions step3-graphClusteringPCAGenes.R
Original file line number Diff line number Diff line change
Expand Up @@ -367,22 +367,22 @@ rownames(annot) <- samplesToPlot\n", file=fileWithAllCommands,append=T)
col = colors
)
cat("pheatmap(
sampleDistMatrix,
clustering_distance_rows = sampleDists,
clustering_distance_cols = sampleDists,
cellwidth = 10,
cellheight = 10,
annotation = annot,
annotation_colors = fixedColors,
main=\"Euclidean distance - complete clustering\",
col = colors,
clustering_method=\"complete\"
sampleDistMatrix,
clustering_distance_rows = sampleDists,
clustering_distance_cols = sampleDists,
cellwidth = 10,
cellheight = 10,
annotation = annot,
annotation_colors = fixedColors,
main=\"Euclidean distance - complete clustering\",
col = colors,
clustering_method=\"complete\"
)\n", file=fileWithAllCommands,append=T)
if(usePng){
dev.off()
png(paste0(outputFolder,"/CorrelationMatrix_EuclWard.png"),width=pngSize,height=pngSize)
cat("dev.off()
png(paste0(outputFolder,\"/CorrelationMatrix_EuclWard.png\"),width=",pngSize,",height=",pngSize,")\n", file=fileWithAllCommands,append=T)
png(paste0(outputFolder,\"/CorrelationMatrix_EuclWard.png\"),width=",pngSize,",height=",pngSize,")\n", file=fileWithAllCommands,append=T)
}
pheatmap(
sampleDistMatrix,
Expand All @@ -397,47 +397,51 @@ rownames(annot) <- samplesToPlot\n", file=fileWithAllCommands,append=T)
col = colors
)
cat("pheatmap(
sampleDistMatrix,
clustering_distance_rows = sampleDists,
clustering_distance_cols = sampleDists,
cellwidth = 10,
cellheight = 10,
annotation = annot,
annotation_colors = fixedColors,
main=\"Euclidean distance - ward clustering\",
clustering_method=\"ward.D2\",
col = colors
sampleDistMatrix,
clustering_distance_rows = sampleDists,
clustering_distance_cols = sampleDists,
cellwidth = 10,
cellheight = 10,
annotation = annot,
annotation_colors = fixedColors,
main=\"Euclidean distance - ward clustering\",
clustering_method=\"ward.D2\",
col = colors
)\n", file=fileWithAllCommands,append=T)
if(usePng){
dev.off()
png(paste0(outputFolder,"/CorrelationMatrix_SpearWard.png"),width=pngSize,height=pngSize)
cat("dev.off()
png(paste0(outputFolder,\"/CorrelationMatrix_SpearWard.png\"),width=",pngSize,",height=",pngSize,")\n", file=fileWithAllCommands,append=T)
png(paste0(outputFolder,\"/CorrelationMatrix_SpearWard.png\"),width=",pngSize,",height=",pngSize,")\n", file=fileWithAllCommands,append=T)
}
correlationMatrix <- cor(rldata, method="spearman")
newSampleDist <- as.dist(1 - correlationMatrix)
pheatmap(
1-cor(rldata,method="spearman"),
clustering_distance_rows = sampleDists,
clustering_distance_cols = sampleDists,
correlationMatrix,
clustering_distance_rows = newSampleDist,
clustering_distance_cols = newSampleDist,
cellwidth = 10,
cellheight = 10,
annotation = annot,
annotation_colors = fixedColors,
main="1-spearmanCor - ward clustering",
main="spearmanCor - ward clustering",
clustering_method="ward.D2",
col = colors
col = rev(colors)
)
dev.off()
cat("pheatmap(
1-cor(rldata,method=\"spearman\"),
clustering_distance_rows = sampleDists,
clustering_distance_cols = sampleDists,
cellwidth = 10,
cellheight = 10,
annotation = annot,
annotation_colors = fixedColors,
main=\"1-spearmanCor - ward clustering\",
clustering_method=\"ward.D2\",
col = colors
cat("correlationMatrix <- cor(rldata, method=\"spearman\")
newSampleDist <- as.dist(1 - correlationMatrix)
pheatmap(
correlationMatrix,
clustering_distance_rows = newSampleDist,
clustering_distance_cols = newSampleDist,
cellwidth = 10,
cellheight = 10,
annotation = annot,
annotation_colors = fixedColors,
main=\"spearmanCor - ward clustering\",
clustering_method=\"ward.D2\",
col = rev(colors)
)
dev.off()\n", file=fileWithAllCommands,append=T)
}
Expand Down

0 comments on commit ee823c9

Please sign in to comment.