cancel
Showing results for 
Search instead for 
Did you mean: 

Relationship with the initial code

iganea9
Node Link

We have developed a model for data processing in neo4j. These are the nodes :Experiment , :Variety , :Compound , :Parameter and the relationships between them. To specify from which variety is the value of the parameter we specified the paid property with the id of the relationship between variety and compound, but it is not specified how to connect to the initial node (: Experiment) . How can we specify from which experiment was the parameter value obtained?
// Experiment → Variety (id:3)
MATCH (a), (b)
WHERE id (a) = 15 AND id (b) = 3
CREATE (a) - [ rel : PROCESSED ] -> (b); //id:0
//Var. -> Compound
MATCH (a), (b)
WHERE id (a) = 3 AND id (b) = 24
CREATE (a) - [ rel : TREATED {paid: 0}] -> (b);

// Root length (cm)
// Compound -> Param (RL)
MATCH (a ), (b)
WHERE id ( a ) = 24 AND id (b) = 26
CREATE ( a ) - [ rel : MEASURES { cm : 9.65, paid: 1, paid: 0 }] -> (b );
//Experiment 12-07-21
// Experiment → Variety
MATCH ( a ), ( b )
WHERE id ( a ) = 20 AND id ( b ) = 3
CREATE ( a ) - [ rel : PROCESSED ] -> ( b );
// Variety → Compound
MATCH ( a ), ( b )
WHERE id ( a ) = 3 AND id ( b ) = 24
CREATE ( a ) - [ rel : TREATED{paid: 5} ] -> ( b );
// Root length (cm)
// Biovit
MATCH ( a ), ( b )
WHERE id ( a ) = 24 AND id ( b ) = 26
CREATE ( a ) - [ rel : MEASURES { cm : 14, paid: 3 }] -> ( b );

How to determine which experiment (Exp1 or Exp2) is the Root Length value (26). I used the paid property for Variety (3).
3X_2_6_2690027f815606a3c28d4e8fcf64b82a8c224fb5.png

16 REPLIES 16

glilienfield
Ninja
Ninja

I am a little confused with the data model. It seems you have parallel paths traversing through the same nodes, so it is challenging to know which relationship belongs to a path when there are multiple ones of the same type between two nodes. I assume that is what the ‘paid’ attribute is trying to accomplish, discriminating between relationships. Does each experiment have unique paths from itself to the root length node? If so, could you use the unique identifier of the experiment node as the ‘paid’ attribute for every relationship along that experiment node’s path to the root length node, instead of accumulating them along the path from the relationship ids? You would then need to check every relationship has a ‘paid’ attribute equal to the experiment node when pattern matching.

Sorry if I am way off because I don’t have enough understanding of your problem domain.

Thanks for the reply.
The same paths are used. In each experiment, data on certain plant varieties that are treated with certain compound are analyzed. Next, some parameters are analyzed, such as root length, stem length, stem mass, root mass, etc.
The paid attribute (id of relationship) is used to identify the variety , but does not specify which experiment it is from. paid: 3, 0 (0 -> id variety; 3 -> id experiment) does not work.

id(a) means you are selecting a node where node id = 3 and this number is assigned by Neo4j during node creation.

If 'id' is a property of the node, then you should use a.id = 3

glilienfield
Ninja
Ninja

I may be getting closer to understanding, but maybe not. My interpretation from your description is that an experiment is on a specific variety of plant. That plant can be treated with one or more compounds. You then collect measurements and analyze the impact of each compound on the plant. You also have a control group for determining a baseline to compare the compounds against. If this is true, it seems logical that you could set a property in each relationship associated with this experiment that equals the experiment's unique id. You could then traverse the paths from experiment through variety, compounds, and then root length by constraining the relationships to those that have the experiment id property set to the experiment you are interested in analyzing.

If this doesn't work, would you consider a different data model? The fact that the compounds of an experiment are not directly related to the experiment results in the ambiguous parallel paths. making it difficult to associated the relationships back to its corresponding experiment. How about something like below:

3X_b_1_b180d8d8165dca553229bdf718723a8495839222.png

The compounds are general and contain meta data describing the compound. The specifics of the compound to this experiment are saved in the "TREATED_WITH" relationship, such as quantity, mixture, etc. You could also store the measures and analytic results in the relationships, as the results are from the specific experiment and compound combination.

From this, you should be able to determine such things as all experiments a compound was used in, all experiments on a specific variety, all compounds used on a plant variety, or all varieties a compound was treated with, etc. You can get all the experiment inputs and analytic data by linking the experiment of interest with the control group and compounds and outputting the analytics. You can also compare the results of a specific compound on a specific variety over several experiments that have different experimental parameters.

Just some thoughts...I don't know if I am making sense, since I am not very familiar with your problem. My apologies if I am off.

Your understanding is correct. I used the ID of the relation between experiment and variety with the „paid” property. In the model you proposed it’s not specified which variety we treated with which compound. Using this model I have to find out what is the impact of each compound on a certain parameter (root length, stem length, root biomass, stem biomass etc.), what’s the interdependency between root length and stem length, root/stem length and productivity etc.
Thanks for suggestion.

glilienfield
Ninja
Ninja

I was thinking an experiment is an instance when you apply a specific combination of compounds to a single variety. Each time you vary the quantity and compounds for that variety, it would be another experiment. As such, after two experiments, you would have a graph like the following:

the measure nodes are where you would record the results of the experiment once completed and they are recorded. You would have the impact of the combination of compounds by seeing the change in your metrics against the control group measurements. From this graph, you should be able to get a summary of the impact of each combination of compounds for the given variety, which is the root node of the graph. Each variety would have its own graph linking its experiments with compounds and results.

If I am still overlooking something and the original model is still preferred, I think you can link all the paths together from an experiment to a root length node by using a unique identifier. Something like below will label all relationships along the desired path with the same uuid as assigned to the experiment node.

MATCH ( a ) WHERE id ( a ) = 20
SET a.uuid = randomUUID()
WITH a, a.uuid as uuid
MATCH( b ) WHERE id ( b ) = 3
CREATE ( a ) - [ rel:PROCESSED ] -> ( b )
SET rel.uuid = uuid
WITH a, b, uuid
MATCH ( c ) WHERE id ( c ) = 24
CREATE ( b ) - [ rel:TREATED{paid: 5} ] -> ( c )
SET rel.uuid = uuid
WITH a, b, c, uuid
MATCH ( d ) WHERE id ( d ) = 26
CREATE ( c ) - [ rel:MEASURES { cm : 14, paid: 3 }] -> ( d )
SET rel.uuid = uuid
RETURN uuid, a, b, c, d

With this, you should be able to find the path specific to an experiment using its uuid, as follows:

MATCH p = ( a:Experiment {uuid: $uuid} ) - [ :PROCESSED ] -> ( b ) - [ :TREATED ] -> ( c ) - [  :MEASURES ] -> ( d ) 
WHERE all ( r in relationships(p) WHERE r.uuid = $uuid )
RETURN a, b, c, d

Maybe this helps. If not, sorry for taking your time.

I think the uuid option is the best. I tried to make relationships for the whole experiment to use uuid, but extra nodes are created and there is no relationship between the variety node (in this model I used only one variety) and parameters (Protein content, N2, P2, P2O5).
CREATE (var1: Variety {var: 'S1C'}),
(var2: Variety {var: 'S2D'}), (var3: Variety {var: 'S3H'}),;
// Experiments
CREATE (npp: Experiment {exp: 'N2_P2_Prot'});
// Biostimulatory
CREATE (control: Compound {comp: 'Control'}), (bvt: Compound { comp: 'Bvt'}), (reg: Compound { Compound: 'Reg'});
// Parameters
CREATE(prot: Parameter{param: 'Protein'}),
(n2: Parameter{param: 'N2'}),
(p2: Parameter{param: 'P2'}),
(p2o5: Parameter{param: 'P2O5'}),
//Exp Prot_N_P -> Cont. Prot, N2, P2, P2O5
MATCH ( exp ) WHERE id ( exp ) = 19 //exp
SET exp . uuid = randomUUID ( )
WITH exp , exp . uuid as uuid
MATCH ( var ) WHERE id ( var ) = 3 //var
MERGE ( exp ) - [ rel : PROCESSED ] -> ( var )
SET rel . uuid = uuid
WITH exp , var , uuid
MATCH ( ctrl ) WHERE id ( ctrl ) = 21
MERGE ( var ) - [ rel : NOT_TREATED ] -> ( ctrl ) //var->control
SET rel . uuid = uuid
WITH exp , var , ctrl , uuid
MATCH ( bvt ) WHERE id ( bvt ) = 24 //var->bvt
MERGE ( var ) - [ rel : TREATED_WITH ] -> ( bvt )
SET rel . uuid = uuid
WITH exp , var , bvt , uuid
MATCH ( reg ) WHERE id ( reg ) = 25 //var->reg
MERGE ( var ) - [ rel : TREATED_WITH ] -> ( reg )
SET rel . uuid = uuid
WITH exp , var , reg , uuid
//Compounds->params
MATCH ( prot ) WHERE id ( prot ) = 39 //Control->prot
MERGE ( ctrl ) - [ rel : CONTAINS { % : 33.563 }] -> ( prot )
SET rel . uuid = uuid
WITH exp , var , ctrl , prot , uuid
MATCH ( prot ) WHERE id ( prot ) = 39 //Control->param
MERGE ( bvt ) - [ rel : CONTAINS { % : 37.667 }] -> ( prot ) //bvt->param
SET rel . uuid = uuid
WITH exp , var , bvt , prot , uuid
MATCH ( prot ) WHERE id ( prot ) = 39 //Control->param
MERGE ( reg ) - [ rel : CONTAINS { % : 38.793 }] -> ( prot )
SET rel . uuid = uuid
WITH exp , var , reg , prot , uuid
//Compounds->n2
MATCH ( n2 ) WHERE id ( n2 ) = 42 //Control->param
MERGE ( ctrl ) - [ rel : CONTAINS { % : 5.37 }] -> ( n2 )
SET rel . uuid = uuid
WITH exp , var , ctrl , n2 , uuid
MATCH ( n2 ) WHERE id ( n2 ) = 42 //bvt->param
MERGE ( bvt ) - [ rel : CONTAINS { % : 6.0207 }] -> ( n2 ) //bvt->param
SET rel . uuid = uuid
WITH exp , var , bvt , n2 , uuid
MATCH ( n2 ) WHERE id ( n2 ) = 42 //bvt->param
MERGE ( reg ) - [ rel : CONTAINS { % : 2.2027 }] -> ( n2 )
SET rel . uuid = uuid
WITH exp , var , reg , n2 , uuid
//Compounds->p2
MATCH ( p2 ) WHERE id ( p2 ) = 43 //Control->param
MERGE ( ctrl ) - [ rel : CONTAINS { mg : 342.98 }] -> ( p2 )
SET rel . uuid = uuid
WITH exp , var , ctrl , p2 , uuid
MATCH ( p2 ) WHERE id ( p2 ) = 43 //Control->param
MERGE ( bvt ) - [ rel : CONTAINS { mg : 536.79 }] -> ( p2 ) //bvt->param
SET rel . uuid = uuid
WITH exp , var , bvt , p2 , uuid
MATCH ( p2 ) WHERE id ( p2 ) = 43 //Control->param
MERGE ( reg ) - [ rel : CONTAINS { mg : 361.78 }] -> ( p2 )
SET rel . uuid = uuid
WITH exp , var , reg , p2 , uuid
//Compounds->p2o5
MATCH ( p2o5 ) WHERE id ( p2o5 ) = 44 //Control->param
MERGE ( ctrl ) - [ rel : CONTAINS { mg : 7854.2 }] -> ( p2o5 )
SET rel . uuid = uuid
WITH exp , var , ctrl , p2o5 , uuid
MATCH ( p2o5 ) WHERE id ( p2o5 ) = 44 //Control->param
MERGE ( bvt ) - [ rel : CONTAINS { mg : 12293 }] -> ( p2o5 ) //bvt->param
SET rel . uuid = uuid
WITH exp , var , bvt , p2o5 , uuid
MATCH ( p2o5 ) WHERE id ( p2o5 ) = 44 //reg->param
MERGE ( reg ) - [ rel : CONTAINS { mg : 8284.8 }] -> ( p2o5 ) //reg->param
SET rel.uuid = uuid

iganea9
Node Link

Thanks so much. I apologize for taking so much of your time as it's on me. In the first model, for each utilization of a compound, a new node must be created.

I think the last model is what I need. Although it's not clear which uuid must be used (to which nod or relationship it belongs).

The paid property must point the ID of the relationship to the initial nod. But the ID is not unique. The nods and relations have the same IDs. For example: id:3 belongs to the node S3C and, at the some time, to the relationship Experiment 2 -> Variety S1D. I do not know if it can be used anymore. Instead, maybe we should use CREATE (a) - [rel: CONTAINS {%: 5.37, exp:19, var:3}] -> (b); but the variables exp, var must be defined. As a result of the execution of the instruction, I get this error:

glilienfield
Ninja
Ninja

No worries, I enjoy helping if I can. I feel like I am taking your time.

In terms of the proposed model, I assumed the compound nodes would represent that compound in general. It would be linked to any experiment that treated the experiment's variety with that compound. The compound parameters associated with the treatment of the variety with the compound would be stored as properties in the relationship linking the experiment to the compound. As such, only one Compound node would be needed for entire graph.

In terms of the original model, maybe the node and relationship ids are not appropriate, since node and relationships are not unique among nodes and relationships. You could use your own assigned unique keys. You could also use keys that a more representative of what the id represents rather than 'paid'. This way you would know which id represented a node or relationship.

An alternative is the uuid approach I mentioned. It labels each path from experiment to root node with a unique identifier, so you can traverse the path.

The code was intended to pass the uuid as a parameters. I changed the code below to query for experiment with id = 20.

MATCH p = ( a:Experiment ) - [ :PROCESSED ] -> ( b ) - [ :TREATED ] -> ( c ) - [  :MEASURES ] -> ( d ) 
WHERE id(a) = 20  // id of the experiment of interest
AND all ( r in relationships(p) WHERE r.uuid = a.uuid )
RETURN a, b, c, d

glilienfield
Ninja
Ninja

I found it difficult to use the neo4j id for matching, as the values change each time I recreated the data, and they don't match yours. I added an 'id' property to each node, so I can match on the same value each time. The other thing I found that was causing extra nodes to be created was not passing all variables through the 'with' statements. I ended up rearranging the order of operations so all the 'with' clauses are not necessary.

The following code seems to work. It links all the nodes together and each relationship has the same uuid as the experiment.

// Varieties
CREATE (var1: Variety {id: 1, var: 'S1C'}), (var2: Variety {id: 2, var: 'S2D'}), (var3: Variety {id: 3, var: 'S3H'});

// Experiments
CREATE (npp: Experiment {id: 1, exp: 'N2_P2_Prot'});

// Biostimulatory
CREATE (control: Compound {id: 1, comp: 'Control'}), (bvt: Compound { id: 2, comp: 'Bvt'}), (reg: Compound { id: 3, comp: 'Reg'});

// Parameters
CREATE(prot: Parameter{id: 1, param: 'Protein'}), (n2: Parameter{id: 2, param: 'N2'}), (p2: Parameter{id: 3, param: 'P2'}), (p2o5: Parameter{id: 4, param: 'P2O5'});


//Exp Prot_N_P -> Cont. Prot, N2, P2, P2O5
MATCH ( exp :Experiment ) WHERE exp.id = 1 //exp
SET exp.uuid = randomUUID ( )
WITH exp , exp.uuid as uuid
MATCH ( var :Variety) WHERE var.id = 1 //var
MATCH ( ctrl:Compound ) WHERE ctrl.id = 1
MATCH ( bvt:Compound ) WHERE bvt.id = 2 //var->bvt
MATCH ( reg :Compound) WHERE reg.id = 3 //var->reg
MATCH ( prot :Parameter) WHERE prot.id = 1 //Control->prot
MATCH ( n2:Parameter ) WHERE n2.id = 2 //Control->param
MATCH ( p2o5:Parameter ) WHERE p2o5.id =  4 //Control->param
MATCH ( p2:Parameter ) WHERE p2.id = 3 //Control->param

MERGE ( exp ) - [ rel1 : PROCESSED ] -> ( var )
SET rel1 . uuid = uuid

MERGE ( var ) - [ rel2 : NOT_TREATED ] -> ( ctrl ) //var->control
SET rel2 . uuid = uuid

MERGE ( var ) - [ rel3 : TREATED_WITH ] -> ( bvt )
SET rel3 . uuid = uuid

MERGE ( var ) - [ rel4 : TREATED_WITH ] -> ( reg )
SET rel4 . uuid = uuid

MERGE ( ctrl ) - [ rel5: CONTAINS { percent : 33.563 }] -> ( prot )
SET rel5 . uuid = uuid

MERGE ( bvt ) - [ rel6: CONTAINS { percent : 37.667 }] -> ( prot ) //bvt->param
SET rel6. uuid = uuid

MERGE ( reg ) - [ rel7 : CONTAINS { percent : 38.793 }] -> ( prot )
SET rel7. uuid = uuid

//Compounds->n2

MERGE ( ctrl ) - [ rel8 : CONTAINS { percent : 5.37 }] -> ( n2 )
SET rel8 . uuid = uuid

MERGE ( bvt ) - [ rel9: CONTAINS { percent : 6.0207 }] -> ( n2 ) //bvt->param
SET rel9 . uuid = uuid

MERGE ( reg ) - [ rel10: CONTAINS { percent : 2.2027 }] -> ( n2 )
SET rel10. uuid = uuid

//Compounds->p2

MERGE ( ctrl ) - [ rel11: CONTAINS { mg : 342.98 }] -> ( p2 )
SET rel11 . uuid = uuid

MERGE ( bvt ) - [ rel12 : CONTAINS { mg : 536.79 }] -> ( p2 ) //bvt->param
SET rel12. uuid = uuid

MERGE ( reg ) - [ rel13 : CONTAINS { mg : 361.78 }] -> ( p2 )
SET rel13 . uuid = uuid

//Compounds->p2o5

MERGE ( ctrl ) - [ rel14 : CONTAINS { mg : 7854.2 }] -> ( p2o5 )
SET rel14 . uuid = uuid

MERGE ( bvt ) - [ rel15 : CONTAINS { mg : 12293 }] -> ( p2o5 ) //bvt->param
SET rel15 . uuid = uuid

MERGE ( reg ) - [ rel16 : CONTAINS { mg : 8284.8 }] -> ( p2o5 ) //reg->param
SET rel16.uuid = uuid

Thank you very much for your help and I apologize for the inconvenience. It is the best model, but I want to add other varieties and it is not clear to which varieties the parameters refer. I have modified it in several ways but there are errors.

//Exp Prot_N_P -> Cont. Prot, N2, P2, P2O5
MATCH ( exp :Experiment ) WHERE exp.id = 8 //exp
SET exp.uuid = randomUUID ( )
WITH exp , exp.uuid as uuid

MATCH ( clav :Variety) WHERE clav.id = 1 //var Clavera
SET clav.uuid = uuid 
WITH clav , clav.uuid as uuid

MATCH ( dor :Variety) WHERE dor.id = 2 //var Dorința
SET dor.uuid = uuid
WITH dor, dor.uuid as uuid

MATCH ( horb :Variety) WHERE horb.id = 11 //var Horb
SET horb.uuid = uuid 
WITH horb , horb.uuid as uuid

MATCH ( ctrl:Compound ) WHERE ctrl.id = 1
MATCH ( bvt:Compound ) WHERE bvt.id = 2 
MATCH ( reg :Compound) WHERE reg.id = 3 

MATCH ( prot :Parameter) WHERE prot.id = 1 
MATCH ( n2:Parameter ) WHERE n2.id = 2 
MATCH ( p2:Parameter ) WHERE p2.id = 3 
MATCH ( p2o5:Parameter ) WHERE p2o5.id =  4
 
	//Exp -> Var
MERGE ( exp ) - [ rel1 : PROCESSED ] -> (clav )
SET rel1 . uuid = uuid
MERGE ( exp ) - [ rel2 : PROCESSED ] -> (dor )
SET rel2 . uuid = uuid
MERGE ( exp ) - [ rel3 : PROCESSED ] -> (horb )
SET rel3 . uuid = uuid(0)
	
//Clavera -> Biostims
MERGE ( clav) - [ rel4 : NOT_TREATED ] -> ( ctrl ) 
SET rel4 . uuid = uuid
MERGE ( clav ) - [ rel5 : TREATED_WITH ] -> ( bvt )
SET rel5 . uuid = uuid
MERGE ( clav ) - [ rel6 : TREATED_WITH ] -> ( reg )
SET rel6 . uuid = uuid
//Dorința -> Biostims
MERGE ( dor) - [ rel7 : NOT_TREATED ] -> ( ctrl ) 
SET rel7 . uuid = uuid
MERGE ( dor ) - [ rel8 : TREATED_WITH ] -> ( bvt )
SET rel8 . uuid = uuid
MERGE ( dor ) - [ rel9 : TREATED_WITH ] -> ( reg )
SET rel9 . uuid = uuid
//Horb -> Biostims
MERGE ( horb) - [ rel10 : NOT_TREATED ] -> ( ctrl ) 
SET rel10 . uuid = uuid
MERGE ( horb ) - [ rel11 : TREATED_WITH ] -> ( bvt )
SET rel11 . uuid = uuid
MERGE ( horb ) - [ rel12 : TREATED_WITH ] -> ( reg )
SET rel12 . uuid = uuid

	//Clavera -> Params
MERGE ( ctrl ) - [ rel13: CONTAINS { percent : 33.563 }] -> ( prot )
SET rel13 . uuid = uuid
WITH clav , clav.uuid as uuid

MERGE ( bvt ) - [ rel14: CONTAINS { percent : 37.667 }] -> ( prot ) 
SET rel14. uuid = uuid

MERGE ( reg ) - [ rel15 : CONTAINS { percent : 38.793 }] -> ( prot )
SET rel15. uuid = uuid
WITH clav , clav.uuid as uuid

MERGE ( ctrl ) - [ rel16 : CONTAINS { percent : 5.37 }] -> ( n2 )
SET rel16 . uuid = uuid

MERGE ( bvt ) - [ rel17: CONTAINS { percent : 6.0207 }] -> ( n2 ) //bvt->param
SET rel17 . uuid = uuid
WITH clav , clav.uuid as uuid

MERGE ( reg ) - [ rel18: CONTAINS { percent : 6.2027 }] -> ( n2 )
SET rel18. uuid = uuid
WITH clav , clav.uuid as uuid

MERGE ( ctrl ) - [ rel19: CONTAINS { mg : 342.98 }] -> ( p2 )
SET rel19 . uuid = uuid
WITH clav , clav.uuid as uuid

MERGE ( bvt ) - [ rel20 : CONTAINS { mg : 536.79 }] -> ( p2 ) //bvt->param
SET rel20. uuid = uuid
WITH clav , clav.uuid as uuid

MERGE ( reg ) - [ rel21 : CONTAINS { mg : 361.78 }] -> ( p2 )
SET rel21 . uuid = uuid
WITH clav , clav.uuid as uuid

MERGE ( ctrl ) - [ rel22 : CONTAINS { mg : 7854.2 }] -> ( p2o5 )
SET rel22 . uuid = uuid
WITH clav , clav.uuid as uuid

MERGE ( bvt ) - [ rel23 : CONTAINS { mg : 12293 }] -> ( p2o5 ) //bvt->param
SET rel23 . uuid = uuid
WITH clav , clav.uuid as uuid

MERGE ( reg ) - [ rel24 : CONTAINS { mg : 8284.8 }] -> ( p2o5 ) //reg->param
SET rel24.uuid = uuid
WITH clav , clav.uuid as uuid

//Dor -> Params
MERGE ( ctrl ) - [ rel25: CONTAINS { percent : 35.42 }] -> ( prot )
SET rel25 . uuid = uuid
WITH dor , dor.uuid as uuid

MERGE ( bvt ) - [ rel26: CONTAINS { percent : 36.08 }] -> ( prot ) 
SET rel26. uuid = uuid
WITH dor , dor.uuid as uuid

MERGE ( reg ) - [ rel27 : CONTAINS { percent : 35.896 }] -> ( prot )
SET rel27. uuid = uuid
WITH dor , dor.uuid as uuid

MERGE ( ctrl ) - [ rel28 : CONTAINS { percent : 5.67 }] -> ( n2 )
SET rel28 . uuid = uuid
WITH dor , dor.uuid as uuid

MERGE ( bvt ) - [ rel29: CONTAINS { percent : 5.77 }] -> ( n2 ) //bvt->param
SET rel29 . uuid = uuid
WITH dor , dor.uuid as uuid

MERGE ( reg ) - [ rel30: CONTAINS { percent : 5.74 }] -> ( n2 )
SET rel30. uuid = uuid
WITH dor , dor.uuid as uuid

MERGE ( ctrl ) - [ rel31: CONTAINS { mg : 365.586 }] -> ( p2 )
SET rel31 . uuid = uuid
WITH dor , dor.uuid as uuid

MERGE ( bvt ) - [ rel32 : CONTAINS { mg : 390.89 }] -> ( p2 ) //bvt->param
SET rel32. uuid = uuid
WITH dor , dor.uuid as uuid

MERGE ( reg ) - [ rel33 : CONTAINS { mg : 415.556 }] -> ( p2 )
SET rel33 . uuid = uuid
WITH dor , dor.uuid as uuid

MERGE ( ctrl ) - [ rel34 : CONTAINS { mg : 8371.936 }] -> ( p2o5 )
SET rel34 . uuid = uuid
MERGE ( bvt ) - [ rel35 : CONTAINS { mg : 8951.38 }] -> ( p2o5 ) //bvt->param
SET rel35 . uuid = uuid
WITH dor , dor.uuid as uuid

MERGE ( reg ) - [ rel36 : CONTAINS { mg : 9516.246 }] -> ( p2o5 ) //reg->param
SET rel36.uuid = uuid
WITH dor , dor.uuid as uuid

//Horb -> Params
MERGE ( ctrl ) - [ rel37: CONTAINS { percent : 37.336 }] -> ( prot )
SET rel37 . uuid = uuid
WITH horb , horb.uuid as uuid

MERGE ( bvt ) - [ rel38: CONTAINS { percent : 38.5 }] -> ( prot ) 
SET rel38. uuid = uuid
WITH horb , horb.uuid as uuid
MERGE ( reg ) - [ rel39 : CONTAINS { percent : 37.583 }] -> ( prot )
SET rel39. uuid = uuid
WITH horb , horb.uuid as uuid
MERGE ( ctrl ) - [ rel40 : CONTAINS { percent : 5.973 }] -> ( n2 )
SET rel40 . uuid = uuid
WITH horb , horb.uuid as uuid
MERGE ( bvt ) - [ rel41: CONTAINS { percent : 6.16 }] -> ( n2 ) //bvt->param
SET rel41 . uuid = uuid
WITH horb , horb.uuid as uuid
MERGE ( reg ) - [ rel42: CONTAINS { percent : 6.013 }] -> ( n2 )
SET rel42. uuid = uuid
WITH horb , horb.uuid as uuid
MERGE ( ctrl ) - [ rel43: CONTAINS { mg : 353.413 }] -> ( p2 )
SET rel43 . uuid = uuid

MERGE ( bvt ) - [ rel44 : CONTAINS { mg : 398.533 }] -> ( p2 ) //bvt->param
SET rel44. uuid = uuid
WITH horb , horb.uuid as uuid
MERGE ( reg ) - [ rel45 : CONTAINS { mg : 501.326 }] -> ( p2 )
SET rel45 . uuid = uuid
WITH horb , horb.uuid as uuid
MERGE ( ctrl ) - [ rel46 : CONTAINS { mg : 8093.163 }] -> ( p2o5 )
SET rel46 . uuid = uuid
WITH horb , horb.uuid as uuid
MERGE ( bvt ) - [ rel47 : CONTAINS { mg : 9126.413 }] -> ( p2o5 ) //bvt->param
SET rel47 . uuid = uuid
WITH horb , horb.uuid as uuid
MERGE ( reg ) - [ rel48 : CONTAINS { mg : 11480.38 }] -> ( p2o5 ) //reg-> param
SET rel48.uuid = uuid
WITH horb , horb.uuid as uuid

glilienfield
Ninja
Ninja

what are the errors? Can you send the cypher to create the nodes, so I can test?

// Experiments
CREATE (npp: Experiment {id: 8, exp: 'N2_P2_Protein'});
//Varieties
CREATE (clavera: Variety {id: 1, var: 'Clavera'}), (dor: Variety {id: 2, var: 'Dorinta'}), (horb: Variety {id: 11, var: 'Horboveanca'});
// Biostimulatory

CREATE (ctrl: Compound {id: 1, ctrl: 'Control'}), (bvt: Compound {id: 4, comp: 'Biovit'}), (reg: Compound {id: 5, comp: 'Reglalg'});
// Parameters
CREATE (prot: Parameter{id: 14, param: 'Protein'}),
(n2: Parameter{id: 17, param: 'N2'}),
(p2: Parameter{id: 18, param: 'P2'}),
(p2o5: Parameter{id: 19, param: 'P2O5'});

Variable `dor` not defined (line 107, column 6 (offset: 3403))
"WITH dor , dor.uuid as uuid"
      ^

glilienfield
Ninja
Ninja

The error states the 'dor' variable is not defined. The cause is the 'dor' value derived on line 10 not being passed through the chain of 'with' clauses to where it was needed on line 107. The parameter id's where also not aligned in the script.

The following seems to work. I removed unnecessary 'with' clauses.

//Exp Prot_N_P -> Cont. Prot, N2, P2, P2O5
with randomUUID() as uuid
MATCH ( exp :Experiment ) WHERE exp.id = 8 //exp
SET exp.uuid = uuid
WITH uuid, exp

MATCH ( clav :Variety) WHERE clav.id = 1 //var Clavera
SET clav.uuid = uuid 
WITH clav, uuid, exp

MATCH ( dor :Variety) WHERE dor.id = 2 //var Dorința
SET dor.uuid = uuid
WITH clav, dor, uuid, exp

MATCH ( horb :Variety) WHERE horb.id = 11 //var Horb
SET horb.uuid = uuid 
WITH clav, dor, horb , uuid, exp

MATCH ( ctrl:Compound ) WHERE ctrl.id = 1
MATCH ( bvt:Compound ) WHERE bvt.id = 4
MATCH ( reg :Compound) WHERE reg.id = 5 

MATCH ( prot :Parameter) WHERE prot.id = 14
MATCH ( n2:Parameter ) WHERE n2.id = 17
MATCH ( p2:Parameter ) WHERE p2.id = 18
MATCH ( p2o5:Parameter ) WHERE p2o5.id =  19
 
	//Exp -> Var
MERGE ( exp ) - [ rel1 : PROCESSED ] -> (clav )
SET rel1 . uuid = uuid
MERGE ( exp ) - [ rel2 : PROCESSED ] -> (dor )
SET rel2 . uuid = uuid
MERGE ( exp ) - [ rel3 : PROCESSED ] -> (horb )
SET rel3 . uuid = uuid
	
//Clavera -> Biostims
MERGE ( clav) - [ rel4 : NOT_TREATED ] -> ( ctrl ) 
SET rel4 . uuid = uuid
MERGE ( clav ) - [ rel5 : TREATED_WITH ] -> ( bvt )
SET rel5 . uuid = uuid
MERGE ( clav ) - [ rel6 : TREATED_WITH ] -> ( reg )
SET rel6 . uuid = uuid

//Dorința -> Biostims
MERGE ( dor) - [ rel7 : NOT_TREATED ] -> ( ctrl ) 
SET rel7 . uuid = uuid
MERGE ( dor ) - [ rel8 : TREATED_WITH ] -> ( bvt )
SET rel8 . uuid = uuid
MERGE ( dor ) - [ rel9 : TREATED_WITH ] -> ( reg )
SET rel9 . uuid = uuid

//Horb -> Biostims
MERGE ( horb) - [ rel10 : NOT_TREATED ] -> ( ctrl ) 
SET rel10 . uuid = uuid
MERGE ( horb ) - [ rel11 : TREATED_WITH ] -> ( bvt )
SET rel11 . uuid = uuid
MERGE ( horb ) - [ rel12 : TREATED_WITH ] -> ( reg )
SET rel12 . uuid = uuid

	//Clavera -> Params
MERGE ( ctrl ) - [ rel13: CONTAINS { percent : 33.563 }] -> ( prot )
SET rel13 . uuid = uuid

MERGE ( bvt ) - [ rel14: CONTAINS { percent : 37.667 }] -> ( prot ) 
SET rel14. uuid = uuid

MERGE ( reg ) - [ rel15 : CONTAINS { percent : 38.793 }] -> ( prot )
SET rel15. uuid = uuid

MERGE ( ctrl ) - [ rel16 : CONTAINS { percent : 5.37 }] -> ( n2 )
SET rel16 . uuid = uuid

MERGE ( bvt ) - [ rel17: CONTAINS { percent : 6.0207 }] -> ( n2 ) //bvt->param
SET rel17 . uuid = uuid

MERGE ( reg ) - [ rel18: CONTAINS { percent : 6.2027 }] -> ( n2 )
SET rel18. uuid = uuid

MERGE ( ctrl ) - [ rel19: CONTAINS { mg : 342.98 }] -> ( p2 )
SET rel19 . uuid = uuid

MERGE ( bvt ) - [ rel20 : CONTAINS { mg : 536.79 }] -> ( p2 ) //bvt->param
SET rel20. uuid = uuid

MERGE ( reg ) - [ rel21 : CONTAINS { mg : 361.78 }] -> ( p2 )
SET rel21 . uuid = uuid

MERGE ( ctrl ) - [ rel22 : CONTAINS { mg : 7854.2 }] -> ( p2o5 )
SET rel22 . uuid = uuid

MERGE ( bvt ) - [ rel23 : CONTAINS { mg : 12293 }] -> ( p2o5 ) //bvt->param
SET rel23 . uuid = uuid

MERGE ( reg ) - [ rel24 : CONTAINS { mg : 8284.8 }] -> ( p2o5 ) //reg->param
SET rel24.uuid = uuid

//Dor -> Params
MERGE ( ctrl ) - [ rel25: CONTAINS { percent : 35.42 }] -> ( prot )
SET rel25 . uuid = uuid

MERGE ( bvt ) - [ rel26: CONTAINS { percent : 36.08 }] -> ( prot ) 
SET rel26. uuid = uuid

MERGE ( reg ) - [ rel27 : CONTAINS { percent : 35.896 }] -> ( prot )
SET rel27. uuid = uuid

MERGE ( ctrl ) - [ rel28 : CONTAINS { percent : 5.67 }] -> ( n2 )
SET rel28 . uuid = uuid

MERGE ( bvt ) - [ rel29: CONTAINS { percent : 5.77 }] -> ( n2 ) //bvt->param
SET rel29 . uuid = uuid

MERGE ( reg ) - [ rel30: CONTAINS { percent : 5.74 }] -> ( n2 )
SET rel30. uuid = uuid

MERGE ( ctrl ) - [ rel31: CONTAINS { mg : 365.586 }] -> ( p2 )
SET rel31 . uuid = uuid

MERGE ( bvt ) - [ rel32 : CONTAINS { mg : 390.89 }] -> ( p2 ) //bvt->param
SET rel32. uuid = uuid

MERGE ( reg ) - [ rel33 : CONTAINS { mg : 415.556 }] -> ( p2 )
SET rel33 . uuid = uuid

MERGE ( ctrl ) - [ rel34 : CONTAINS { mg : 8371.936 }] -> ( p2o5 )
SET rel34 . uuid = uuid

MERGE ( bvt ) - [ rel35 : CONTAINS { mg : 8951.38 }] -> ( p2o5 ) //bvt->param
SET rel35 . uuid = uuid

MERGE ( reg ) - [ rel36 : CONTAINS { mg : 9516.246 }] -> ( p2o5 ) //reg->param
SET rel36.uuid = uuid

//Horb -> Params
MERGE ( ctrl ) - [ rel37: CONTAINS { percent : 37.336 }] -> ( prot )
SET rel37 . uuid = uuid

MERGE ( bvt ) - [ rel38: CONTAINS { percent : 38.5 }] -> ( prot ) 
SET rel38. uuid = uuid

MERGE ( reg ) - [ rel39 : CONTAINS { percent : 37.583 }] -> ( prot )
SET rel39. uuid = uuid

MERGE ( ctrl ) - [ rel40 : CONTAINS { percent : 5.973 }] -> ( n2 )
SET rel40 . uuid = uuid

MERGE ( bvt ) - [ rel41: CONTAINS { percent : 6.16 }] -> ( n2 ) //bvt->param
SET rel41 . uuid = uuid

MERGE ( reg ) - [ rel42: CONTAINS { percent : 6.013 }] -> ( n2 )
SET rel42. uuid = uuid

MERGE ( ctrl ) - [ rel43: CONTAINS { mg : 353.413 }] -> ( p2 )
SET rel43 . uuid = uuid

MERGE ( bvt ) - [ rel44 : CONTAINS { mg : 398.533 }] -> ( p2 ) //bvt->param
SET rel44. uuid = uuid

MERGE ( reg ) - [ rel45 : CONTAINS { mg : 501.326 }] -> ( p2 )
SET rel45 . uuid = uuid

MERGE ( ctrl ) - [ rel46 : CONTAINS { mg : 8093.163 }] -> ( p2o5 )
SET rel46 . uuid = uuid

MERGE ( bvt ) - [ rel47 : CONTAINS { mg : 9126.413 }] -> ( p2o5 ) //bvt->param
SET rel47 . uuid = uuid

MERGE ( reg ) - [ rel48 : CONTAINS { mg : 11480.38 }] -> ( p2o5 ) //reg-> param
SET rel48.uuid = uuid

Is this what you want? Are you going to overlay another set of connections between all these nodes for each experiment you track?

Thank you very much for your help.
The same nodes (Control, Biovit, Reglalg etc.) must be processed for each experiment :Variety and :Parameters.
I think I'll use the model you proposed.

glilienfield
Ninja
Ninja

Give it a try. They graph is very complicated and will get worse each experiment.

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.