Env<-read.csv("Filename.csv") ##--Loads file into R-- Env2<-Env[,-1] ##--Removes "Filename" column from file, enabling R to work on the matrix-- Env20000<-log10(Env2) ##--Logs the resulting matrix-- EnvM<-data.matrix(Env20000) rm(Env20000) BREAKS<-c(0,0.001,0.01,0.1,1,1000000) counts<-hist(x=EnvM,breaks=BREAKS)$count rm(BREAKS) RND<-runif(counts[1],0.0001,0.0099) ind<-which(EnvM==0,arr.ind=TRUE) for (i in 1:counts[1]) { EnvM[ind[i,1],ind[i,2]]<-RND[i] } rm(counts) ##--Replaces zeroes in matrix with random numbers (quicker!)-- merged20000.res<-EMclust(EnvM,G=1:10) ##--performs MBC operation on matrix-- plot(merged20000.res) ##--plots BIC vs cluster number-- merged20000.resF<-EMclust(EnvM,G=SelectedClusterNumber,"Modelname") ##--Performs MBC operation on the chosen model name and number of clusters-- merged20000.resG<-summary(merged20000.resF,EnvM) ##--Shows the number of spectra included in each cluster and creates matrix table-- merged20000.resG ##--prints number of spectra in each cluster mz20000a<-merged20000.resG$mu ##--Creates a table of mass/charge values and cluster numbers-- write.table(mz20000a, file = "mz2000a.csv", sep = ",") ##--Writes the resulting values to a CSV file to be viewed in Excel--