Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-24-2020 05:50 PM
Hi,
I am trying to bulid the relationship between my nodes.
However, the "variable not defined "error messages keep pop up in my neo4j browser, even though the variable existed.
When I run this
LOAD CSV WITH HEADERS FROM 'file:///genes2hallmark.csv' AS link
MATCH (g:gene{ENS_ID: topTable.ID}),(hmgs:HMGS{hallmark_gene_sets: hmgenesets.hallmark_genesets})
WITH g, hmgs
MERGE (g)-[r:BELONG]->(hmgs)
Gives me the error message:
Variable
topTable
not defined (line 2, column 23 (offset: 86))
"MATCH (g:gene{ENS_ID: topTable.ID}),(hmgs:HMGS{hallmark_gene_sets: hmgenesets.hallmark_genesets})"
Anyone can give me a hints about this?
Thank you so much.
USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM 'file:///hmgs.csv' AS hmgenesets
MERGE (hmgs:HMGS{hallmark_gene_sets: hmgenesets.hallmark_genesets})
WITH hmgs
MATCH (hmgs)
RETURN (hmgs)
USING PERIODIC COMMIT 500
LOAD CSV WITH HEADERS FROM 'file:///topTable.csv' AS topTable
MERGE (g:gene
{ENS_ID: topTable.ID,
log_FG: topTable.logFC,
Average_Expression: topTable.AveExpr,
t_test: topTable.t,
P_value: topTable.P_Value,
Adjusted_P_value: topTable.adj_P_Val,
entrez_id: topTable.entrezid,
gene_name: topTable.gene_name})
WITH (g)
MATCH (g)
RETURN (g)
LOAD CSV WITH HEADERS FROM 'file:///genes2hallmark.csv' AS link
MATCH (g:gene{ENS_ID: topTable.ID}),(hmgs:HMGS{hallmark_gene_sets: hmgenesets.hallmark_genesets})
WITH g, hmgs
MERGE (g)-[r:BELONG]->(hmgs)
The topTable.csv looks like this:
ID,logFC,AveExpr,t,P_Value,adj_P_Val,entrezid,gene_name
E971,3,8,3,8,1,5,FO
E938,3,8,3,8,1,5,F
The geneshallmark.csv looks like this:
gene_id,geneset
E938,HALLMARK_A
E971,HALLMARK_C
E971,HALLMARK_C
The hmgs.csv looks like this:
hallmark_genesets
HALLMARK_A
HALLMARK_C
Solved! Go to Solution.
02-25-2020 05:25 AM
Hi, you are referring to a variable defined in another query.
Here the variable available for you is "link"
gene_id,geneset
E938,HALLMARK_A
E971,HALLMARK_C
E971,HALLMARK_C
Based on this data set change the code to
LOAD CSV WITH HEADERS FROM 'file:///genes2hallmark.csv' AS link
MATCH (g:gene{ENS_ID: link.gene_id}),(hmgs:HMGS{hallmark_gene_sets: link.geneset})
WITH g, hmgs
MERGE (g)-[r:BELONG]->(hmgs)
This should work.
02-25-2020 03:05 AM
Where exactly are you getting the variable does not exist error?
02-25-2020 03:42 AM
Hi,
Thank you for your reply.
The error message is
Variable
topTable
not defined (line 2, column 23 (offset: 86))
"MATCH (g:gene{ENS_ID: topTable.ID}),(hmgs:HMGS{hallmark_gene_sets: hmgenesets.hallmark_genesets})"
So the I think it stands for the variable topTable is not defined. But I defined it in
USING PERIODIC COMMIT 500
LOAD CSV WITH HEADERS FROM 'file:///topTable.csv' AS topTable
02-25-2020 04:14 AM
Ok, it looks like the problem is you're calling that topTable, without providing the ID. Yes you've created it, but you would need to provide the ID again as a parameter. You can't simply just call it again. You need to have a list of the IDs you're trying to call and match to the links. You could probably collect the ids before hand and loop through them like:
MATCH (g:gene)
with COLLECT(g.ENS_ID) as ids
......
Then you'd be able to match them correctly and go on.
02-25-2020 05:25 AM
Hi, you are referring to a variable defined in another query.
Here the variable available for you is "link"
gene_id,geneset
E938,HALLMARK_A
E971,HALLMARK_C
E971,HALLMARK_C
Based on this data set change the code to
LOAD CSV WITH HEADERS FROM 'file:///genes2hallmark.csv' AS link
MATCH (g:gene{ENS_ID: link.gene_id}),(hmgs:HMGS{hallmark_gene_sets: link.geneset})
WITH g, hmgs
MERGE (g)-[r:BELONG]->(hmgs)
This should work.
02-25-2020 06:14 PM
Thank you so much for your reply.
It works!
All the sessions of the conference are now available online