Search in sources :

Example 1 with BooleanGlassGenePm

use of edu.cmu.tetrad.gene.tetradapp.model.BooleanGlassGenePm in project tetrad by cmu-phil.

the class BooleanGlassSimulation method createData.

@Override
public void createData(Parameters parameters) {
    this.graph = randomGraph.createGraph(parameters);
    LagGraphParams params = new LagGraphParams(parameters);
    params.setIndegree(2);
    params.setMlag(1);
    RandomActiveLagGraph _graph = new RandomActiveLagGraph(params);
    BooleanGlassGenePm pm = new BooleanGlassGenePm(_graph);
    BooleanGlassGeneIm im = new BooleanGlassGeneIm(pm, parameters);
    DataModelList data = im.simulateData();
    List<DataSet> dataSets = new ArrayList<>();
    for (DataModel model : data) {
        dataSets.add((DataSet) model);
    }
    this.dataSets = dataSets;
    List<String> factors = new ArrayList<>(_graph.getFactors());
    Map<String, Node> nodes = new HashMap<>();
    for (String factor : factors) {
        nodes.put(factor, new ContinuousVariable(factor));
    }
    TimeLagGraph graph = new TimeLagGraph();
    graph.setMaxLag(_graph.getMaxLag());
    for (String factor : factors) {
        graph.addNode(nodes.get(factor));
    }
    for (String factor : factors) {
        for (Object o : _graph.getParents(factor)) {
            LaggedFactor laggedFactor = (LaggedFactor) o;
            String _factor = laggedFactor.getFactor();
            int lag = laggedFactor.getLag();
            Node node1 = graph.getNode(_factor + ":" + lag);
            Node node2 = graph.getNode(factor);
            graph.addDirectedEdge(node1, node2);
        }
    }
    topToBottomLayout(graph);
    this.graph = graph;
}
Also used : LagGraphParams(edu.cmu.tetrad.gene.tetrad.gene.graph.LagGraphParams) BooleanGlassGenePm(edu.cmu.tetrad.gene.tetradapp.model.BooleanGlassGenePm) Node(edu.cmu.tetrad.graph.Node) BooleanGlassGeneIm(edu.cmu.tetrad.gene.tetradapp.model.BooleanGlassGeneIm) RandomActiveLagGraph(edu.cmu.tetrad.gene.tetrad.gene.graph.RandomActiveLagGraph) TimeLagGraph(edu.cmu.tetrad.graph.TimeLagGraph) LaggedFactor(edu.cmu.tetrad.gene.tetrad.gene.history.LaggedFactor)

Aggregations

LagGraphParams (edu.cmu.tetrad.gene.tetrad.gene.graph.LagGraphParams)1 RandomActiveLagGraph (edu.cmu.tetrad.gene.tetrad.gene.graph.RandomActiveLagGraph)1 LaggedFactor (edu.cmu.tetrad.gene.tetrad.gene.history.LaggedFactor)1 BooleanGlassGeneIm (edu.cmu.tetrad.gene.tetradapp.model.BooleanGlassGeneIm)1 BooleanGlassGenePm (edu.cmu.tetrad.gene.tetradapp.model.BooleanGlassGenePm)1 Node (edu.cmu.tetrad.graph.Node)1 TimeLagGraph (edu.cmu.tetrad.graph.TimeLagGraph)1