3765B47A0F77D15900C3EDC5 /* nocommands.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3765B4780F77D15900C3EDC5 /* nocommands.cpp */; };
3765B4E20F78055000C3EDC5 /* sharedochiai.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3765B4E10F78055000C3EDC5 /* sharedochiai.cpp */; };
3765B5160F780A7F00C3EDC5 /* sharedanderberg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3765B5150F780A7F00C3EDC5 /* sharedanderberg.cpp */; };
+ 3765B5380F7A5A9E00C3EDC5 /* heatmapcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3765B5370F7A5A9E00C3EDC5 /* heatmapcommand.cpp */; };
+ 3765B5460F7A62A000C3EDC5 /* heatmap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3765B5450F7A62A000C3EDC5 /* heatmap.cpp */; };
3782163D0F616079008E1F6D /* fullmatrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3782163C0F616079008E1F6D /* fullmatrix.cpp */; };
379293C30F2DE73400B9034A /* treemap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 379293C20F2DE73400B9034A /* treemap.cpp */; };
379294700F2E191800B9034A /* parsimonycommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3792946F0F2E191800B9034A /* parsimonycommand.cpp */; };
3765B4E10F78055000C3EDC5 /* sharedochiai.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedochiai.cpp; sourceTree = "<group>"; };
3765B5140F780A7F00C3EDC5 /* sharedanderberg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedanderberg.h; sourceTree = "<group>"; };
3765B5150F780A7F00C3EDC5 /* sharedanderberg.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedanderberg.cpp; sourceTree = "<group>"; };
+ 3765B5360F7A5A9E00C3EDC5 /* heatmapcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = heatmapcommand.h; sourceTree = "<group>"; };
+ 3765B5370F7A5A9E00C3EDC5 /* heatmapcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = heatmapcommand.cpp; sourceTree = "<group>"; };
+ 3765B5440F7A62A000C3EDC5 /* heatmap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = heatmap.h; sourceTree = "<group>"; };
+ 3765B5450F7A62A000C3EDC5 /* heatmap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = heatmap.cpp; sourceTree = "<group>"; };
3782163B0F616079008E1F6D /* fullmatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fullmatrix.h; sourceTree = "<group>"; };
3782163C0F616079008E1F6D /* fullmatrix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fullmatrix.cpp; sourceTree = "<group>"; };
379293C10F2DE73400B9034A /* treemap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = treemap.h; sourceTree = "<group>"; };
37D927DD0F21331F001D4494 /* fileoutput.cpp */,
37D927E00F21331F001D4494 /* globaldata.hpp */,
37D927DF0F21331F001D4494 /* globaldata.cpp */,
+ 3765B5440F7A62A000C3EDC5 /* heatmap.h */,
+ 3765B5450F7A62A000C3EDC5 /* heatmap.cpp */,
37D927E60F21331F001D4494 /* inputdata.h */,
37D927E50F21331F001D4494 /* inputdata.cpp */,
37D927EA0F21331F001D4494 /* kmer.hpp */,
A70B53A60F4CD7AD0064797E /* getlabelcommand.cpp */,
A70B53A90F4CD7AD0064797E /* getlinecommand.h */,
A70B53A80F4CD7AD0064797E /* getlinecommand.cpp */,
+ 3765B5360F7A5A9E00C3EDC5 /* heatmapcommand.h */,
+ 3765B5370F7A5A9E00C3EDC5 /* heatmapcommand.cpp */,
37D927E40F21331F001D4494 /* helpcommand.h */,
37D927E30F21331F001D4494 /* helpcommand.cpp */,
374CD63D0F65832000D90B4A /* libshuffcommand.h */,
217595590F792490001CC3C6 /* sharedlennon.cpp in Sources */,
217595640F7927BB001CC3C6 /* sharedmorisitahorn.cpp in Sources */,
217595710F792A33001CC3C6 /* sharedbraycurtis.cpp in Sources */,
+ 3765B5380F7A5A9E00C3EDC5 /* heatmapcommand.cpp in Sources */,
+ 3765B5460F7A62A000C3EDC5 /* heatmap.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
else if (globaldata->getGroupFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared, rarefaction.shared or summary.shared commands." << endl; return false; }
}
}
+
+ if (commandName == "heatmap"){
+ if ((globaldata->getListFile() == "") && (globaldata->getSharedFile() == "")) {
+ cout << "You must read a list, or a list and a group, or a shared before you can use the heatmap command." << endl; return false;
+ }
+ }
return errorFree;
}
--- /dev/null
+/*
+ * heatmap.cpp
+ * Mothur
+ *
+ * Created by Sarah Westcott on 3/25/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "heatmap.h"
+
+//**********************************************************************************************************************
+HeatMap::HeatMap(){
+ try {
+ globaldata = GlobalData::getInstance();
+ format = globaldata->getFormat();
+
+ if (format != "list") { setGroups(); }
+
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function HeatMap. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the HeatMap class function HeatMap. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+void HeatMap::getPic(OrderVector* order) {
+ try {
+ sabund = order->getSAbundVector();
+ string filename = getRootName(globaldata->inputFileName) + order->getLabel();
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the HeatMap class function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+void HeatMap::getPic(SharedOrderVector* sharedorder) {
+ try {
+ getSharedVectors(sharedorder);
+
+
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the HeatMap class function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+void HeatMap::getSharedVectors(SharedOrderVector* order){
+ try {
+ lookup.clear();
+
+ vector<SharedRAbundVector*> templookup;
+
+ //create and initialize vector of sharedvectors, one for each group
+ for (int i = 0; i < globaldata->Groups.size(); i++) {
+ SharedRAbundVector* temp = new SharedRAbundVector(order->getNumBins());
+ temp->setLabel(order->getLabel());
+ temp->setGroup(globaldata->Groups[i]);
+ templookup.push_back(temp);
+ }
+
+ int numSeqs = order->size();
+ //sample all the members
+ for(int i=0;i<numSeqs;i++){
+ //get first sample
+ individual chosen = order->get(i);
+ int abundance;
+
+ //set info for sharedvector in chosens group
+ for (int j = 0; j < templookup.size(); j++) {
+ if (chosen.group == templookup[j]->getGroup()) {
+ abundance = templookup[j]->getAbundance(chosen.bin);
+ templookup[j]->set(chosen.bin, (abundance + 1), chosen.group);
+ break;
+ }
+ }
+ }
+
+ //convert templookups rabunds to lookups sabunds
+ for (int j = 0; j < templookup.size(); j++) {
+ lookup.push_back(templookup[j]->getSharedSAbundVector());
+ delete templookup[j];
+ }
+
+
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function getSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the HeatMap class function getSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+
+}
+
+//**********************************************************************************************************************
+void HeatMap::setGroups() {
+ try {
+ //if the user has not entered specific groups to analyze then do them all
+ if (globaldata->Groups.size() != 0) {
+ if (globaldata->Groups[0] != "all") {
+ //check that groups are valid
+ for (int i = 0; i < globaldata->Groups.size(); i++) {
+ if (globaldata->gGroupmap->isValidGroup(globaldata->Groups[i]) != true) {
+ cout << globaldata->Groups[i] << " is not a valid group, and will be disregarded." << endl;
+ // erase the invalid group from globaldata->Groups
+ globaldata->Groups.erase(globaldata->Groups.begin()+i);
+ }
+ }
+
+ //if the user only entered invalid groups
+ if (globaldata->Groups.size() == 0) {
+ cout << "When using the groups parameter you must have at least 1 valid groups. I will run the command using all the groups in your groupfile." << endl;
+ for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) {
+ globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]);
+ }
+ }
+ }else{//user has enter "all" and wants the default groups
+ globaldata->Groups.clear();
+ for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) {
+ globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]);
+ }
+ globaldata->setGroups("");
+ }
+ }else {
+ for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) {
+ globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]);
+ }
+ }
+
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the HeatMap class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+
+}
+/***********************************************************/
--- /dev/null
+#ifndef HEATMAP_H
+#define HEATMAP_H
+/*
+ * heatmap.h
+ * Mothur
+ *
+ * Created by Sarah Westcott on 3/25/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+using namespace std;
+
+#include "ordervector.hpp"
+#include "sabundvector.hpp"
+#include "sharedsabundvector.h"
+#include "sharedordervector.h"
+#include "datavector.hpp"
+#include "globaldata.hpp"
+
+/***********************************************************************/
+
+class HeatMap {
+
+ public:
+ HeatMap();
+ ~HeatMap(){};
+
+ void getPic(OrderVector*);
+ void getPic(SharedOrderVector*);
+
+ private:
+ void getSharedVectors(SharedOrderVector*);
+ void setGroups();
+
+ GlobalData* globaldata;
+ vector<SharedSAbundVector> lookup;
+ SAbundVector sabund;
+ string format;
+
+
+};
+
+#endif
+
--- /dev/null
+/*
+ * heatmapcommand.cpp
+ * Mothur
+ *
+ * Created by Sarah Westcott on 3/25/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "heatmapcommand.h"
+
+
+//**********************************************************************************************************************
+
+HeatMapCommand::HeatMapCommand(){
+ try {
+ globaldata = GlobalData::getInstance();
+ format = globaldata->getFormat();
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the HeatMapCommand class Function HeatMapCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the HeatMapCommand class function HeatMapCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+
+HeatMapCommand::~HeatMapCommand(){
+ delete input;
+ delete read;
+}
+
+//**********************************************************************************************************************
+
+int HeatMapCommand::execute(){
+ try {
+ int count = 1;
+
+ if (format == "sharedfile") {
+ //you have groups
+ read = new ReadPhilFile(globaldata->inputFileName);
+ read->read(&*globaldata);
+
+ input = globaldata->ginput;
+ order = input->getSharedOrderVector();
+ }else if (format == "shared") {
+ //you are using a list and a groupfile
+ read = new ReadPhilFile(globaldata->inputFileName);
+ read->read(&*globaldata);
+
+ input = globaldata->ginput;
+ SharedList = globaldata->gSharedList;
+ order = SharedList->getSharedOrderVector();
+ }else if (format == "list") {
+ //you are using just a list file and have only one group
+ read = new ReadPhilFile(globaldata->inputFileName);
+ read->read(&*globaldata);
+
+ ordersingle = globaldata->gorder;
+ input = globaldata->ginput;
+ }
+
+ if (format != "list") {
+ while(order != NULL){
+
+ if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){
+
+ cout << order->getLabel() << '\t' << count << endl;
+//call heatmap class to make file
+ }
+
+ //get next line to process
+ if (format == "sharedfile") {
+ order = input->getSharedOrderVector();
+ }else {
+ //you are using a list and a groupfile
+ SharedList = input->getSharedListVector(); //get new list vector to process
+ if (SharedList != NULL) {
+ order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
+ }else {
+ break;
+ }
+ }
+ count++;
+ }
+
+ //reset groups parameter
+ globaldata->Groups.clear(); globaldata->setGroups("");
+
+ }else{
+ while(ordersingle != NULL){
+
+ if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){
+
+ cout << order->getLabel() << '\t' << count << endl;
+//call heatmap class to make file
+ }
+
+ ordersingle = (input->getOrderVector());
+ count++;
+ }
+ }
+
+ return 0;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the HeatMapCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the HeatMapCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+
+//**********************************************************************************************************************
+
--- /dev/null
+#ifndef HEATMAPCOMMAND_H
+#define HEATMAPCOMMAND_H
+
+/*
+ * heatmapcommand.h
+ * Mothur
+ *
+ * Created by Sarah Westcott on 3/25/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+
+#include "command.hpp"
+#include "inputdata.h"
+#include "readmatrix.hpp"
+#include "sharedlistvector.h"
+
+
+class GlobalData;
+
+
+class HeatMapCommand : public Command {
+
+public:
+ HeatMapCommand();
+ ~HeatMapCommand();
+ int execute();
+
+private:
+ GlobalData* globaldata;
+ ReadMatrix* read;
+ InputData* input;
+ SharedListVector* SharedList;
+ SharedOrderVector* order;
+ OrderVector* ordersingle;
+ string format;
+
+};
+
+#endif
+
//store in temps to avoid multiple repetitive function calls
tempA = shared1->getAbundance(i);
tempB = shared2->getAbundance(i);
-
- S1 += tempA;
- S2 += tempB;
+
+ //find number of bins in shared1 and shared2
+ if (tempA != 0) { S1++; }
+ if (tempB != 0) { S2++; }
//they are shared
if ((tempA != 0) && (tempB != 0)) { S12++; }
tempA = shared1->getAbundance(i);
tempB = shared2->getAbundance(i);
- S1 += tempA;
- S2 += tempB;
+ //find number of bins in shared1 and shared2
+ if (tempA != 0) { S1++; }
+ if (tempB != 0) { S2++; }
//they are shared
if ((tempA != 0) && (tempB != 0)) { S12++; }
commands["unifrac.weighted"] = "unifrac.weighted";
commands["unifrac.unweighted"] = "unifrac.unweighted";
commands["libshuff"] = "libshuff";
+ commands["heatmap"] = "heatmap";
commands["get.group"] = "get.group";
commands["get.label"] = "get.label";
commands["get.line"] = "get.line";
}
cout << endl;
return false; }
+ }else if (command == "heatmap") {
+ //is it valid
+ if ((heatmap.find(parameter)) != (heatmap.end())) {
+ return true;
+ }else {
+ cout << parameter << " is not a valid parameter for the " + command + " command. Valid parameters are ";
+ for (it = heatmap.begin(); it != heatmap.end(); it++) {
+ cout << it->first << ", ";
+ }
+ cout << endl;
+ return false; }
+
//not a valid paramter
}else if (command == "help") { cout << parameter << " is not a valid parameter for the " + command + " command. There are no vaild parameters." << endl;
}else if (command == "quit") { cout << parameter << " is not a valid parameter for the " + command + " command. There are no vaild parameters." << endl;
libshuff["form"] = "form";
}
/***********************************************************************/
+void ValidParameters::initialHeatmap() {
+ heatmap["label"] = "label";
+ heatmap["line"] = "line";
+}
+
+/***********************************************************************/
map<string, string> unifracweighted;
map<string, string> unifracunweighted;
map<string, string> libshuff;
+ map<string, string> heatmap;
map<string, string>::iterator it;
void initialUnifracweighted();
void initialUnifracunweighted();
void initialLibshuff();
+ void initialHeatmap();
};