Skip to content

Commit

Permalink
Merge pull request #181 from sumanthreddy542/Cluster-rows-in-HeatMap
Browse files Browse the repository at this point in the history
Update heatmap clustering and dendrogram plot options.
  • Loading branch information
urmi-21 authored Sep 20, 2021
2 parents 68fd86d + 03cde67 commit 6ced6a4
Show file tree
Hide file tree
Showing 28 changed files with 862 additions and 123 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#CI to test MOG build
#Contributor sumanthreddy542
#Contributor Sumanth
name: Maven CI

on:
Expand All @@ -14,7 +14,6 @@ jobs:
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
#os: [windows-latest]

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -51,7 +50,18 @@ jobs:
- name: Installing CustomBrowserLauncher dependency windows
if: ${{ matrix.os == 'windows-latest'}}
run: mvn install:install-file `-Dfile=src/lib/CustomBrowserLauncher.jar `-DgroupId=edu.iastate.metnet `-DartifactId=custombrowserlauncher `-Dversion=0.0.1 `-Dpackaging=jar `-DgeneratePom=true


- name: Downloading hierarchical-clustering zip file
run: curl -LJO https://github.com/lbehnke/hierarchical-clustering-java/releases/download/v1.2.0/hierarchical-clustering-1.2.0.jar

- name: Installing hierarchical-clustering dependency
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
run: mvn install:install-file -Dfile=hierarchical-clustering-1.2.0.jar -DgroupId=com.apporiented -DartifactId=hierarchical-clustering -Dversion=1.2.0 -Dpackaging=jar -DgeneratePom=true

- name: Installing hierarchical-clustering dependency windows
if: ${{ matrix.os == 'windows-latest' }}
run: mvn install:install-file `-Dfile=hierarchical-clustering-1.2.0.jar `-DgroupId=com.apporiented `-DartifactId=hierarchical-clustering `-Dversion=1.2.0 `-Dpackaging=jar `-DgeneratePom=true

- name: Build with Maven
run: mvn -B package --file pom.xml

Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@
<artifactId>tsne</artifactId>
<version>v2.6.3</version>
</dependency>
<dependency>
<groupId>com.apporiented</groupId>
<artifactId>hierarchical-clustering</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>

</project>
4 changes: 2 additions & 2 deletions src/edu/iastate/metnet/metaomgraph/ComputeTSNE.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ public double[][] projectData(){
if(error.contains("Perplexity too large")) {
String errorMessage = error;
errorMessage += "Please set it low, check the user guide for optimal values";
JOptionPane.showMessageDialog(MetaOmGraph.getMainWindow(), errorMessage, "Tsne error", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null, errorMessage, "Tsne error", JOptionPane.ERROR_MESSAGE);
}
else if(error.contains("theta")) {
String errorMessage = "Please set theta more than 0.0";
JOptionPane.showMessageDialog(MetaOmGraph.getMainWindow(), errorMessage, "Tsne error", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null, errorMessage, "Tsne error", JOptionPane.ERROR_MESSAGE);
}
}
catch(Exception e) {
Expand Down
19 changes: 9 additions & 10 deletions src/edu/iastate/metnet/metaomgraph/CorrelationCalc.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private void calcBaseValues() {
}*/
}

private double[] calcRank(double[] data) {
private static double[] calcRank(double[] data) {
SortableData[] myData = new SortableData[data.length];
for (int i = 0; i < myData.length; i++) {
myData[i] = new SortableData(data[i], i);
Expand Down Expand Up @@ -118,7 +118,8 @@ public double pearsonCorrelation(double[] b, boolean hasSkips, Double blankValue
public double pearsonCorrelationStandard(double[] b) {
return pearsonCorrelationStandard(a, b);
}
public double pearsonCorrelationStandard(double[] a,double[] b) {

public static double pearsonCorrelationStandard(double[] a,double[] b) {

if (b.length != a.length) {
JOptionPane.showMessageDialog(null, "Unequal lengths", "Error", JOptionPane.ERROR_MESSAGE);
Expand Down Expand Up @@ -162,8 +163,13 @@ public double pearsonCorrelationStandard(double[] a,double[] b) {
return corr;

}



public static double spearmanCorrelation(double[] a, double[] b) {
double[] rankA = calcRank(a);
double[] rankB = calcRank(b);
return pearsonCorrelationStandard(rankA,rankB);
}

// using apache
public double newSpearmanCorrelation(double[] b) {
Expand Down Expand Up @@ -195,13 +201,6 @@ public double mySpearmanCorrelation(double[] b) {
}









public double euclideanDistance(Object[] b, boolean hasSkips, Double blankValue) {
if ((b == null) || (a == null))
return 0.0D;
Expand Down
56 changes: 30 additions & 26 deletions src/edu/iastate/metnet/metaomgraph/FilterableTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void applyFilterold(String[] values) {
}

private TreeSet<Integer> applyAnyColFilter(String value,
boolean isNotFlag, boolean doesNotFlag, boolean containsFlag){
boolean isNotFlag, boolean doesNotFlag, boolean isFlag){

TreeSet<Integer> hits = new TreeSet();
for (int row = 0; row < model.getRowCount(); row++) {
Expand All @@ -115,13 +115,13 @@ private TreeSet<Integer> applyAnyColFilter(String value,
break;
}
}
else if(containsFlag) {
if(thisValue.contains(value)) {
else if(isFlag) {
if (thisValue.contentEquals(value)) {
hits.add(Integer.valueOf(row));
break;
}
}
else if (thisValue.contentEquals(value)) {
else if(thisValue.contains(value)) {
hits.add(Integer.valueOf(row));
break;
}
Expand All @@ -131,7 +131,7 @@ else if (thisValue.contentEquals(value)) {
}

private TreeSet<Integer> applyAllColsFilter(String value,
boolean isNotFlag, boolean doesNotFlag, boolean containsFlag){
boolean isNotFlag, boolean doesNotFlag, boolean isFlag){

TreeSet<Integer> hits = new TreeSet();
for (int row = 0; row < model.getRowCount(); row++) {
Expand All @@ -153,13 +153,13 @@ private TreeSet<Integer> applyAllColsFilter(String value,
break;
}
}
else if(containsFlag) {
if(!thisValue.contains(value)) {
allFields = false;
break;
else if(isFlag) {
if (!thisValue.contentEquals(value)) {
allFields = false;
break;
}
}
else if (!thisValue.contentEquals(value)) {
else if(!thisValue.contains(value)) {
allFields = false;
break;
}
Expand Down Expand Up @@ -188,29 +188,33 @@ public void applyFilter(String[] values) {
for (String findMe : values) {
boolean isNotFlag = false;
boolean doesNotFlag = false;
boolean containsFlag = false;
if(findMe.charAt(0) == '!') {
isNotFlag = true;
findMe = findMe.substring(1);
} else if(findMe.substring(0, 2).contentEquals("~!")) {
doesNotFlag = true;
findMe = findMe.substring(2);
} else if(findMe.charAt(0) == '~') {
containsFlag = true;
findMe = findMe.substring(1);
boolean isFlag = false;
if(findMe.length() > 1) {
if(findMe.substring(0, 2).contentEquals("!=")) {
isNotFlag = true;
findMe = findMe.substring(2);
} else if(findMe.charAt(0) == '!') {
doesNotFlag = true;
findMe = findMe.substring(1);
} else if(findMe.charAt(0) == '=') {
isFlag = true;
findMe = findMe.substring(1);
}
}
boolean colFlag = false;
int colInt = -1;
boolean allCols = false;
boolean anyCol = false;
boolean anyCol = true;
// delim should be present and should have values on both sides
if (findMe.indexOf(delim) > -1 && findMe.indexOf(delim) < findMe.length() - delim.length()) {
String col = findMe.split(delim)[1];
if(col.contentEquals("ALL")) {
allCols = true;
anyCol = false;
findMe = findMe.split(delim)[0];
} else if(col.contentEquals("ANY")) {
anyCol = true;
allCols = false;
findMe = findMe.split(delim)[0];
} else {
// check if col is a valid integer
Expand Down Expand Up @@ -258,12 +262,12 @@ public void applyFilter(String[] values) {
if(!thisValue.contains(findMe)) {
hits.add(Integer.valueOf(row));
}
} else if(containsFlag) {
if(thisValue.contains(findMe)) {
} else if(isFlag) {
if (thisValue.contentEquals(findMe)) {
hits.add(Integer.valueOf(row));
}
}
else if (thisValue.contentEquals(findMe)) {
else if(thisValue.contains(findMe)) {
hits.add(Integer.valueOf(row));
}
}
Expand All @@ -273,9 +277,9 @@ else if (thisValue.contentEquals(findMe)) {
findMe = findMe.split(caseFlag)[0];
}
if(anyCol) {
hits.addAll(applyAnyColFilter(findMe, isNotFlag, doesNotFlag, containsFlag));
hits.addAll(applyAnyColFilter(findMe, isNotFlag, doesNotFlag, isFlag));
} else if(allCols) {
hits.addAll(applyAllColsFilter(findMe, isNotFlag, doesNotFlag, containsFlag));
hits.addAll(applyAllColsFilter(findMe, isNotFlag, doesNotFlag, isFlag));
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/edu/iastate/metnet/metaomgraph/IconTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public interface IconTheme {
ImageIcon getExternalSource();

ImageIcon getSort();

ImageIcon getClusterIcon();

ImageIcon getExcel();

Expand Down
11 changes: 11 additions & 0 deletions src/edu/iastate/metnet/metaomgraph/JavaIconTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class JavaIconTheme implements IconTheme {
private ImageIcon zoomIn;
private ImageIcon zoomOut;
private ImageIcon sort;
private ImageIcon cluster;
private ImageIcon excel;
private ImageIcon report;
private ImageIcon groupBy;
Expand Down Expand Up @@ -95,6 +96,8 @@ public JavaIconTheme() {
private String rIconPath = "/resource/customicon/r_logoIcon16.png";

private String selectIconPath = "/resource/customicon/select16.png";

private final String clusterIconPath = "/resource/customicon/cluster16.png";

@Override
public ImageIcon getProperties() {
Expand Down Expand Up @@ -295,6 +298,14 @@ public ImageIcon getSort() {
}
return sort;
}

@Override
public ImageIcon getClusterIcon() {
if (cluster == null) {
cluster = new ImageIcon(getClass().getResource(clusterIconPath));
}
return cluster;
}

@Override
public ImageIcon getExcel() {
Expand Down
8 changes: 7 additions & 1 deletion src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -4113,6 +4113,8 @@ private static String downloadProjSelectionPanel(File projDirectory, DownloadSam
destPath += File.separator + "MOG_Athaliana_Metabolomics";
if(Utils.downloadFile(projURL, destPath + ".zip")) {
Utils.unZipFile(destPath + ".zip", destPath);
} else {
destPath = "";
}
} else if (project == DownloadSampleProject.MicroArray) {
try {
Expand All @@ -4124,6 +4126,8 @@ private static String downloadProjSelectionPanel(File projDirectory, DownloadSam
destPath += File.separator + "MOG_Athaliana_MicroArray";
if(Utils.downloadFile(projURL, destPath + ".zip")) {
Utils.unZipFile(destPath + ".zip", destPath);
} else {
destPath = "";
}
} else {
try {
Expand All @@ -4135,14 +4139,16 @@ private static String downloadProjSelectionPanel(File projDirectory, DownloadSam
destPath += File.separator + "MOG_HumanCancerRNASeq";
if(Utils.downloadFile(projURL, destPath + ".zip")) {
Utils.unZipFile(destPath + ".zip", destPath);
} else {
destPath = "";
}
}
return destPath;
}

private static void downloadAndOpenProject(DownloadSampleProject project) {
File currDir = Utils.getLastDir();
File projSelDir = CustomFileSaveDialog.showDirectoryDialog(currDir);
File projSelDir = CustomFileSaveDialog.showDirectoryDialog(currDir, "Save sample project to");
if(projSelDir == null) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/edu/iastate/metnet/metaomgraph/MetaOmTips.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public MetaOmTips() {
tips = new ArrayList();
addTip(
"Welcome to MetaOmGraph!",
"<html><p style=\"color:9ACD32\">You can press F1 at any time to get help with whatever you're working on.\n\nOn some laptops (especially Mac laptops), you may need to press Fn-F1.</p></html>");
"<html><p style=\"color:3335FF\">You can press F1 at any time to get help with whatever you're working on.\n\nOn some laptops (especially Mac laptops), you may need to press Fn-F1.</p></html>");

tipPane = new JTextPane();
tipPane.setEditable(false);
Expand All @@ -62,7 +62,7 @@ public MetaOmTips() {
addTip("Properties",
"<html><p style=\"color:FF00FF\">Plot defaults (axis titles, background gradient), as well as row and column names, can be edited by selecting Project->Properties from the menu bar.</p></html>");
addTip("Saving Metadata sorts",
"<html><p style=\"color:7FFF00\">To quickly re-order any plot to the result of a metadata sort, save the result as a custom sort. Run the metadata sort, then select the custom sort option, then click the Save button.</p></html>");
"<html><p style=\"color:FF4C33\">To quickly re-order any plot to the result of a metadata sort, save the result as a custom sort. Run the metadata sort, then select the custom sort option, then click the Save button.</p></html>");


createTipPanel();
Expand Down
10 changes: 10 additions & 0 deletions src/edu/iastate/metnet/metaomgraph/SilkIconTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class SilkIconTheme implements IconTheme {
private ImageIcon groupBy;
private ImageIcon rIcon;
private ImageIcon selectIcon;
private ImageIcon clusterIcon;

private String defaultZoomPath = "/resource/silkicon/zoom.png";

Expand Down Expand Up @@ -94,6 +95,8 @@ public SilkIconTheme() {
private String rIconPath = "/resource/customicon/r_logoIcon16.png";

private String selectIconPath = "/resource/customicon/select16.png";

private final String clusterIconPath = "/resource/customicon/cluster16.png";

@Override
public ImageIcon getProperties() {
Expand Down Expand Up @@ -363,4 +366,11 @@ public ImageIcon getSelectIcon() {
}
return selectIcon;
}

public ImageIcon getClusterIcon() {
if(clusterIcon == null) {
clusterIcon = new ImageIcon(getClass().getResource(clusterIconPath));
}
return clusterIcon;
}
}
10 changes: 10 additions & 0 deletions src/edu/iastate/metnet/metaomgraph/TangoIconTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class TangoIconTheme implements IconTheme {
private ImageIcon groupBy;
private ImageIcon rIcon;
private ImageIcon selectIcon;
private ImageIcon clusterIcon;

private String dir = "/resource/tango/16x16/";

Expand Down Expand Up @@ -103,6 +104,8 @@ public class TangoIconTheme implements IconTheme {

private String selectIconPath = "/resource/customicon/select16.png";

private final String clusterIconPath = "/resource/customicon/cluster16.png";

public TangoIconTheme() {
}

Expand Down Expand Up @@ -373,6 +376,13 @@ public ImageIcon getSelectIcon() {
return selectIcon;
}

public ImageIcon getClusterIcon() {
if(clusterIcon == null) {
clusterIcon = new ImageIcon(getClass().getResource(clusterIconPath));
}
return clusterIcon;
}

public static void main(String[] args) {
java.lang.reflect.Method[] methods = SilkIconTheme.class.getDeclaredMethods();
IconTheme theme = new SilkIconTheme();
Expand Down
Loading

0 comments on commit 6ced6a4

Please sign in to comment.