Mercurial > hg > plosone_underreview
view scripts_R/PlotOutliersCountry.R @ 105:edd82eb89b4b branch-tests tip
Merge
author | Maria Panteli |
---|---|
date | Sun, 15 Oct 2017 13:36:59 +0100 |
parents | d3e05cd49feb |
children |
line wrap: on
line source
source("MetadataPlots.R") PlotCountryOutliers(df=read.csv("../data/results/global_outliers.csv",header=TRUE), output="../data/results/global_outliers.pdf") PlotCountryOutliers(df=read.csv("../data/results/global_outliers_rhy.csv",header=TRUE), output="../data/results/global_outliers_rhy.pdf") PlotCountryOutliers(df=read.csv("../data/results/global_outliers_mel.csv",header=TRUE), output="../data/results/global_outliers_mel.pdf") PlotCountryOutliers(df=read.csv("../data/results/global_outliers_mfc.csv",header=TRUE), output="../data/results/global_outliers_mfc.pdf") PlotCountryOutliers(df=read.csv("../data/results/global_outliers_chr.csv",header=TRUE), output="../data/results/global_outliers_chr.pdf") PlotCountryOutliers(df=read.csv("../data/results/spatial_outliers.csv",header=TRUE), output="../data/results/spatial_outliers.pdf") library(ape) library(cluster) df = read.csv("../data/results/cluster_freq.csv") data = df[,2:dim(df)[2]] levels(df$labels)[which(levels(df$labels)=="Democratic Republic of the Congo")]="DR Congo" df$labels[which(df$labels=="Democratic Republic of the Congo")] = "DR Congo" rownames(data) <- df$labels distMahal = as.dist(apply(data, 1, function(i) mahalanobis(data, i, cov = cov(data),tol=1e-18))) hc=hclust(distMahal, method="average") mypal = c("#000000", "#9B0000", "#9B0000", "#9B0000", "#9B0000") clus5 = cutree(hc, 4) pdf('../data/results/hierarchical_cluster.pdf', pointsize=12) par(mar=c(1,1,1,1)) plot(as.phylo(hc),type="fan",tip.color=mypal[clus5], cex=.5, label.offset=.5) dev.off() postscript('../data/results/hierarchical_cluster.eps', pointsize=12) par(mar=c(1,1,1,1)) plot(as.phylo(hc),type="fan",tip.color=mypal[clus5], cex=.5, label.offset=.5) dev.off()