objects = {
/* Begin PBXFileReference section */
+ 7EC61A0911BEA6AF00F668D9 /* weightedlinkage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = weightedlinkage.cpp; sourceTree = "<group>"; };
A703FE931194645F002C397E /* makegroupcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = makegroupcommand.h; sourceTree = SOURCE_ROOT; };
A703FE941194645F002C397E /* makegroupcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = makegroupcommand.cpp; sourceTree = SOURCE_ROOT; };
A71D924211AEB42400D00CBC /* clustersplitcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = clustersplitcommand.cpp; sourceTree = "<group>"; };
A7DA2170113FECD400BF472F /* uvest.h */,
A7DA2179113FECD400BF472F /* weighted.cpp */,
A7DA217A113FECD400BF472F /* weighted.h */,
+ 7EC61A0911BEA6AF00F668D9 /* weightedlinkage.cpp */,
A7DA217B113FECD400BF472F /* whittaker.cpp */,
A7DA217C113FECD400BF472F /* whittaker.h */,
);
}
}
//if not merged it you need it for warning
- if ((!merged) && (method == "average")) {
+ if ((!merged) && (method == "average" || method == "weighted")) {
//m->mothurOut("Warning: trying to merge cell " + toString(rowCells[i]->row+1) + " " + toString(rowCells[i]->column+1) + " distance " + toString(rowCells[i]->dist) + " with value above cutoff. Results may vary from using cutoff at cluster command instead of read.dist."); m->mothurOutEndLine();
if (cutOFF > rowCells[i]->dist) {
cutOFF = rowCells[i]->dist;
// could be avoided
for (int i=nColCells-1;i>=0;i--) {
if (foundCol[i] == 0) {
- if (method == "average") {
+ if (method == "average" || method == "weighted") {
if (!((colCells[i]->row == smallRow) && (colCells[i]->column == smallCol))) {
//m->mothurOut("Warning: merging cell " + toString(colCells[i]->row+1) + " " + toString(colCells[i]->column+1) + " distance " + toString(colCells[i]->dist) + " value above cutoff. Results may vary from using cutoff at cluster command instead of read.dist."); m->mothurOutEndLine();
if (cutOFF > colCells[i]->dist) {
/***********************************************************************/
+class WeightedLinkage : public Cluster {
+public:
+ WeightedLinkage(RAbundVector*, ListVector*, SparseMatrix*, float, string);
+ bool updateDistance(MatData& colCell, MatData& rowCell);
+ string getTag();
+
+private:
+ int saveRow;
+ int saveCol;
+};
+
+/***********************************************************************/
+
#endif
method = validParameter.validFile(parameters, "method", false);
if (method == "not found") { method = "furthest"; }
- if ((method == "furthest") || (method == "nearest") || (method == "average")) { }
- else { m->mothurOut("Not a valid clustering method. Valid clustering algorithms are furthest, nearest or average."); m->mothurOutEndLine(); abort = true; }
+ if ((method == "furthest") || (method == "nearest") || (method == "average") || (method == "weighted")) { }
+ else { m->mothurOut("Not a valid clustering method. Valid clustering algorithms are furthest, nearest, average, and weighted."); m->mothurOutEndLine(); abort = true; }
showabund = validParameter.validFile(parameters, "showabund", false);
if (showabund == "not found") { showabund = "T"; }
if (method == "furthest") { cluster = new CompleteLinkage(rabund, list, matrix, cutoff, method); }
else if(method == "nearest"){ cluster = new SingleLinkage(rabund, list, matrix, cutoff, method); }
else if(method == "average"){ cluster = new AverageLinkage(rabund, list, matrix, cutoff, method); }
+ else if(method == "weighted"){ cluster = new WeightedLinkage(rabund, list, matrix, cutoff, method); }
tag = cluster->getTag();
if (outputDir == "") { outputDir += hasPath(globaldata->inputFileName); }
./splitabundcommand.o\\r
./splitmatrix.o\\r
./clustersplitcommand.o\\r
+ ./weightedlinkage.o\\r
./inputdata.o\\r
./jackknife.o\\r
./kmer.o\\r
./splitabundcommand.o\\r
./splitmatrix.o\\r
./clustersplitcommand.o\\r
+ ./weightedlinkage.o\\r
./inputdata.o\\r
./jackknife.o\\r
./kmer.o\\r
./logsd.o\\r
./geom.o\\r
./setlogfilecommand.o\\r
- -o ../Release/mothur\r
+ -o mothur\r
\r
clean : \r
rm \\r
./splitabundcommand.o\\r
./splitmatrix.o\\r
./clustersplitcommand.o\\r
+ ./weightedlinkage.o\\r
./inputdata.o\\r
./jackknife.o\\r
./kmer.o\\r
./classifyotucommand.o : classifyotucommand.cpp\r
$(CC) $(CC_OPTIONS) classifyotucommand.cpp -c $(INCLUDE) -o ./classifyotucommand.o\r
\r
+# Item # 209 -- splitmatrix --\r
+./weightedlinkage.o : weightedlinkage.cpp\r
+ $(CC) $(CC_OPTIONS) weightedlinkage.cpp -c $(INCLUDE) -o ./weightedlinkage.o\r
\r
##### END RUN ####\r
--- /dev/null
+#ifndef WEIGHTEDLINKAGE_H
+#define WEIGHTEDLINKAGE_H
+
+
+#include "mothur.h"
+#include "cluster.hpp"
+#include "rabundvector.hpp"
+#include "sparsematrix.hpp"
+
+/* This class implements the WPGMA, weighted average neighbor clustering algorithm */
+
+/***********************************************************************/
+
+WeightedLinkage::WeightedLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c, string s) :
+ Cluster(rav, lv, dm, c, s)
+{
+ saveRow = -1;
+ saveCol = -1;
+}
+
+
+/***********************************************************************/
+//This function returns the tag of the method.
+string WeightedLinkage::getTag() {
+ return("wn");
+}
+
+
+/***********************************************************************/
+//This function updates the distance based on the average linkage method.
+bool WeightedLinkage::updateDistance(MatData& colCell, MatData& rowCell) {
+ try {
+ if ((saveRow != smallRow) || (saveCol != smallCol)) {
+// rowBin = rabund->get(smallRow);
+// colBin = rabund->get(smallCol);
+// totalBin = rowBin + colBin;
+ saveRow = smallRow;
+ saveCol = smallCol;
+ }
+
+ colCell->dist = (colCell->dist + rowCell->dist) / 2.0;
+
+ return(true);
+ }
+ catch(exception& e) {
+ m->errorOut(e, "WeightedLinkage", "updateDistance");
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+
+
+/***********************************************************************/
+
+#endif