Skip to content

Commit

Permalink
Use 1 as CorrelationValue for same pair instead of 0
Browse files Browse the repository at this point in the history
  • Loading branch information
sumanthreddy542 committed Jul 30, 2021
1 parent 1e322b8 commit c369cf9
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/edu/iastate/metnet/metaomgraph/chart/HeatMapChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@ public Object construct() {
double[][] pairWiseEuclidianDistance = Utils.computePairWiseEuclidianDistances(heatMapData);
HierarchicalClusterData clusteredData = new HierarchicalClusterData(rowNames, pairWiseEuclidianDistance);
List<String> clusteredOrderedData = clusteredData.getClusteredOrderedData();
if(clusteredOrderedData == null || clusteredOrderedData.isEmpty()) {
return null;
}
String[] clusterOrderedRowNames = clusteredOrderedData.stream().toArray(String[]::new);
heatMapData = rearrangeHeatMapDataBasedOnClusters(clusterOrderedRowNames);
if(splitIndex != null) {
Expand Down Expand Up @@ -429,6 +432,9 @@ public Object construct() {
double[][] pairWisePearsonCorrelation = Utils.computePairWisePearsonCorrelations(heatMapData);
HierarchicalClusterData clusteredData = new HierarchicalClusterData(rowNames, pairWisePearsonCorrelation);
List<String> clusteredOrderedData = clusteredData.getClusteredOrderedData();
if(clusteredOrderedData == null || clusteredOrderedData.isEmpty()) {
return null;
}
String[] clusterOrderedRowNames = clusteredOrderedData.stream().toArray(String[]::new);
heatMapData = rearrangeHeatMapDataBasedOnClusters(clusterOrderedRowNames);
if(splitIndex != null) {
Expand Down Expand Up @@ -461,6 +467,9 @@ public Object construct() {
double[][] pairWiseSpearmanCorrelation = Utils.computePairWiseSpearmanCorrelations(heatMapData);
HierarchicalClusterData clusteredData = new HierarchicalClusterData(rowNames, pairWiseSpearmanCorrelation);
List<String> clusteredOrderedData = clusteredData.getClusteredOrderedData();
if(clusteredOrderedData == null || clusteredOrderedData.isEmpty()) {
return null;
}
String[] clusterOrderedRowNames = clusteredOrderedData.stream().toArray(String[]::new);
heatMapData = rearrangeHeatMapDataBasedOnClusters(clusterOrderedRowNames);
if(splitIndex != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,7 @@ public void keyPressed(KeyEvent e) {
}
});
filterField.getDocument().addDocumentListener(new FilterFieldListener());
filterField.setToolTipText("Prefix search text with '~' for \"contains\", '!' for \"is not\", and '~!' for \"does not contain\".");
filterField.setDefaultText("Use semicolon (;) for multiple filters");
filterField.setColumns(30);
searchPanel.add(filterField, "Center");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ public void keyPressed(KeyEvent e) {
}
});
filterField.getDocument().addDocumentListener(new FilterFieldListener());
filterField.setToolTipText("Prefix search text with '~' for \"contains\", '!' for \"is not\", and '~!' for \"does not contain\".");
filterField.setDefaultText("Use semicolon (;) for multiple filters");
filterField.setColumns(20);
searchPanel.add(filterField, "Center");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,7 @@ public void keyPressed(KeyEvent e) {
}
});
filterField.getDocument().addDocumentListener(new FilterFieldListener());
filterField.setToolTipText("Prefix search text with '~' for \"contains\", '!' for \"is not\", and '~!' for \"does not contain\".");
filterField.setDefaultText("Use semicolon (;) for multiple filters");
filterField.setColumns(30);
searchPanel.add(filterField, "Center");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import java.util.ArrayList;
import java.util.List;

import javax.swing.JOptionPane;

import com.apporiented.algorithm.clustering.AverageLinkageStrategy;
import com.apporiented.algorithm.clustering.Cluster;
import com.apporiented.algorithm.clustering.ClusteringAlgorithm;
Expand All @@ -30,9 +32,14 @@ public HierarchicalClusterData(String[] names, double[][] data) {

// do the heirarchical clustering
private void doClustering(double[][] data, String[] names) {
ClusteringAlgorithm algorithm = new DefaultClusteringAlgorithm();
Cluster cluster = algorithm.performClustering(data, names, new AverageLinkageStrategy());
fillClusteredOrderedDataFromChildren(cluster);
try {
ClusteringAlgorithm algorithm = new DefaultClusteringAlgorithm();
Cluster cluster = algorithm.performClustering(data, names, new AverageLinkageStrategy());
fillClusteredOrderedDataFromChildren(cluster);
}catch(Exception e){
JOptionPane.showMessageDialog(null, "Duplicate identifiers found, the feature names should be unique", "Clustering error", JOptionPane.ERROR_MESSAGE);
return;
}
}

// Fill clustered data recursively
Expand Down
10 changes: 10 additions & 0 deletions src/edu/iastate/metnet/metaomgraph/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,11 @@ public static double[][] computePairWisePearsonCorrelations(double[][] data){
}
}

// fill the diagonals with 1
for(int i = 0; i < data.length; i++) {
pairWisePearsonCorrelation[i][i] = 1;
}

// Now, use the lower triangular part to fill the upper triangular part
for(int i = 0; i < data.length; i++) {
for(int j = i + 1; j < data.length; j++) {
Expand All @@ -1619,6 +1624,11 @@ public static double[][] computePairWiseSpearmanCorrelations(double[][] data){
}
}

// fill the diagonals with 1
for(int i = 0; i < data.length; i++) {
pairWiseSpearmanCorrelation[i][i] = 1;
}

// Now, use the lower triangular part to fill the upper triangular part
for(int i = 0; i < data.length; i++) {
for(int j = i + 1; j < data.length; j++) {
Expand Down

0 comments on commit c369cf9

Please sign in to comment.