Skip to content

Commit

Permalink
Merge pull request #1583 from cmu-phil/development
Browse files Browse the repository at this point in the history
7.3.2.
  • Loading branch information
jdramsey authored Apr 12, 2023
2 parents 41db204 + df7a40e commit 70d8220
Show file tree
Hide file tree
Showing 139 changed files with 2,214 additions and 2,880 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,8 @@ tetrad-gui.log
/testboostrap/CalibrationConstraintBased/RFCI/RandomGraph-Vars20-Edges80-Cases1000-BS5-H0.1-a0.001/PAG_v20_e80_c1000_b5_-1.txt
/testboostrap/CalibrationConstraintBased/RFCI/RandomGraph-Vars20-Edges80-Cases1000-BS5-H0.1-a0.001/probs_v20_e80_c1000_b5_-1.txt
/target/

.DS_Store
._.DS_Store
**/.DS_Store
**/._.DS_Store
40 changes: 30 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@ of contributors, and a bit of history.
Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest
version of Tetrad and Causal Command.

All of our code is public and we welcome suggestions, especially suggestions that improve clarity or performance of our code.
## Setting up Java

You will need to set up Java on your machine. For setting up Java, see our Wiki artible, [Setting up Java for Tetrad](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Java-for-Tetrad).

## Tetrad GUI Application

To download the current jar you can use to launch the Tetrad GUI,
click [here](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.3.0/tetrad-gui-7.3.0-launch.jar).
Please delete any old ones you're not using.
To download the current jar you can use to launch the Tetrad GUI, click this link:

The application will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly *
*_greater than version 1.8 (version 8)_**. We find that the most
recent [Corretto JRE/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc)
with long term support (LTS) works well cross-platform.
https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.3.0/tetrad-gui-7.3.0-launch.jar.

You may be able to launch this jar by double clicking the jar file name, though on a Mac, this presents
some [security challenges](https://github.com/cmu-phil/tetrad/wiki/Dealing-with-Tetrad-on-a-Mac:--Security-Issues). In
Expand All @@ -40,14 +37,16 @@ where [g] is the maximum number of Gigabytes you wish to allocate to the process
We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that lets you run Tetrad algorithms at the
command line.

## Python Integration
## Python and R Integration

For Python integration, please see our (still new) [py-tetrad Python project](https://github.com/cmu-phil/py-tetrad),
which shows how to integrate arbitrary Java code in the Tetrad project into a Python workflow using
the [JPype Python project](https://jpype.readthedocs.io/en/latest/).

Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some
Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why).
Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why)

We added [a method to use Tetrad algorithms in R via py-tetrad](https://github.com/cmu-phil/py-tetrad/blob/main/pytetrad/R/). This is work in progress.

## Documentation

Expand All @@ -58,6 +57,8 @@ our [Manual](https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/
If you like to watch thought-provoking lectures, here are
some [lectures on the Center for Causal Discovery site](https://www.ccd.pitt.edu/video-tutorials/).

In addition, here are our [Javadocs](https://www.phil.cmu.edu/tetrad-javadocs/7.3.0/lib/).

## Install

All artifacts are published in
Expand All @@ -83,3 +84,22 @@ try to the extent possible to resolve all reported issues
before [releasing new versions of Tetrad](https://github.com/cmu-phil/tetrad/releases). This may involve moving items to
our [Wish List
](https://github.com/cmu-phil/tetrad/wiki/Current-Wish-List).

## Open Code

All of our code is public and we welcome suggestions, especially suggestions that improve clarity or performance of our code.

If you're writing code using (or for!) Tetrad in either [Java](https://github.com/cmu-phil/tetrad) or [Python](https://github.com/cmu-phil/py-tetrad) (or R, which we're working toward!), thank you! Please contribute if you are doing amazing work, or publish and send us links to your papers. Please keep us abreast of how Tetrad could be improved for your applications; we will do what we can.

## Citation

Please cite as:

```
@inproceedings{ramsey2018tetrad,
title={TETRAD—A toolbox for causal discovery},
author={Ramsey, Joseph D and Zhang, Kun and Glymour, Madelyn and Romero, Ruben Sanchez and Huang, Biwei and Ebert-Uphoff, Imme and Samarasinghe, Savini and Barnes, Elizabeth A and Glymour, Clark},
booktitle={8th international workshop on climate informatics},
year={2018}
}
```
4 changes: 2 additions & 2 deletions data-reader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.github.cmu-phil</groupId>
<artifactId>tetrad</artifactId>
<version>7.3.0</version>
<version>7.3.2</version>
</parent>
<!-- <groupId>io.github.cmu-phil</groupId>-->
<artifactId>data-reader</artifactId>
Expand Down Expand Up @@ -35,7 +35,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.4.1</version>
<version>2.14.2</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.slf4j</groupId>-->
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.cmu-phil</groupId>
<artifactId>tetrad</artifactId>
<version>7.3.0</version>
<version>7.3.2</version>
<packaging>pom</packaging>

<name>Tetrad Project</name>
Expand Down
2 changes: 1 addition & 1 deletion tetrad-gui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.github.cmu-phil</groupId>
<artifactId>tetrad</artifactId>
<version>7.3.0</version>
<version>7.3.2</version>
</parent>

<artifactId>tetrad-gui</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
package edu.cmu.tetradapp.editor;

import edu.cmu.tetrad.algcomparison.algorithm.Algorithm;
import edu.cmu.tetrad.algcomparison.algorithm.oracle.pag.PagSamplingRfci;
import edu.cmu.tetrad.algcomparison.algorithm.oracle.pag.RfciBsc;
import edu.cmu.tetrad.algcomparison.algorithm.oracle.pag.PAG_SAMPLING_RFCI;
import edu.cmu.tetrad.algcomparison.algorithm.oracle.pag.RFCI_BSC;
import edu.cmu.tetrad.algcomparison.utils.TakesIndependenceWrapper;
import edu.cmu.tetrad.algcomparison.utils.UsesScoreWrapper;
import edu.cmu.tetrad.annotation.Score;
Expand Down Expand Up @@ -74,7 +74,7 @@ public void addToPanel(GeneralAlgorithmRunner algorithmRunner) {
Parameters parameters = algorithmRunner.getParameters();

// Hard-coded parameter groups for Rfci-Bsc
if (algorithm instanceof RfciBsc) {
if (algorithm instanceof RFCI_BSC) {
// Phase one: PAG and constraints candidates Searching
String title = algorithm
.getClass().getAnnotation(edu.cmu.tetrad.annotation.Algorithm.class).name();
Expand Down Expand Up @@ -107,7 +107,7 @@ public void addToPanel(GeneralAlgorithmRunner algorithmRunner) {
this.mainPanel.add(createSubPanel(title, params, parameters));
this.mainPanel.add(Box.createVerticalStrut(10));

} else if (algorithm instanceof PagSamplingRfci) {
} else if (algorithm instanceof PAG_SAMPLING_RFCI) {
String title = algorithm.getClass().getAnnotation(edu.cmu.tetrad.annotation.Algorithm.class).name();

Set<String> params = new LinkedHashSet<>();
Expand All @@ -118,13 +118,13 @@ public void addToPanel(GeneralAlgorithmRunner algorithmRunner) {

title = "RFCI Parameters";
params.clear();
params.addAll(PagSamplingRfci.RFCI_PARAMETERS);
params.addAll(PAG_SAMPLING_RFCI.RFCI_PARAMETERS);
this.mainPanel.add(createSubPanel(title, params, parameters));
this.mainPanel.add(Box.createVerticalStrut(10));

title = "Probabilistic Test Parameters";
params.clear();
params.addAll(PagSamplingRfci.PROBABILISTIC_TEST_PARAMETERS);
params.addAll(PAG_SAMPLING_RFCI.PROBABILISTIC_TEST_PARAMETERS);
this.mainPanel.add(createSubPanel(title, params, parameters));
this.mainPanel.add(Box.createVerticalStrut(10));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public GraphFileMenu(GraphEditable editable, JComponent comp, boolean saveOnly)
save.add(new SaveGraph(editable, "R...", SaveGraph.Type.r));
save.add(new SaveGraph(editable, "Dot...", SaveGraph.Type.dot));
save.add(new SaveGraph(editable, "PCALG...", SaveGraph.Type.pcalg));
save.add(new SaveGraph(editable, "lavaan...", SaveGraph.Type.lavaan));

addSeparator();
add(new SaveComponentImage(comp, "Save Graph Image..."));
Expand Down
19 changes: 18 additions & 1 deletion tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/SaveGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class SaveGraph extends AbstractAction {
*/
private final Type type;

public enum Type {text, xml, json, r, dot, pcalg}
public enum Type {text, xml, json, r, dot, pcalg, lavaan}

public SaveGraph(GraphEditable graphEditable, String title, Type type) {
super(title);
Expand Down Expand Up @@ -147,6 +147,23 @@ public void actionPerformed(ActionEvent e) {
try {
String text = GraphPersistence.graphToPcalg(graph);

PrintWriter out = new PrintWriter(file);
out.println(text);
Preferences.userRoot().put("fileSaveLocation", file.getParent());
out.close();
} catch (FileNotFoundException e1) {
e1.printStackTrace();
throw new RuntimeException("Not a directed graph.", e1);
} catch (IllegalArgumentException e1) {

// Probably not a directed graph.
JOptionPane.showMessageDialog(getGraphEditable().getWorkbench(), e1.getMessage());
}
} else if (this.type == Type.lavaan) {
File file = EditorUtils.getSaveFile("graph", "lavaan.txt", parent, false, this.title);
try {
String text = GraphPersistence.graphToLavaan(graph);

PrintWriter out = new PrintWriter(file);
out.println(text);
Preferences.userRoot().put("fileSaveLocation", file.getParent());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public double getCorrelationPValue() {
}

private double fisherz(double r) {
return 0.5 * FastMath.sqrt(getSampleSize() - 3.0) * (log(1.0 + r) - log(1.0 - r));
return 0.5 * FastMath.sqrt(getSampleSize() - 3.0) * (FastMath.log(1.0 + r) - FastMath.log(1.0 - r));
}

/**
Expand Down
Loading

0 comments on commit 70d8220

Please sign in to comment.