-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcounts_by_study.cypher
29 lines (27 loc) · 1.92 KB
/
counts_by_study.cypher
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
MATCH (st:study)<-[:of_participant]-(p:participant)
where st.phs_accession='phs002517'
with st, count(p) as num_p
MATCH (st)<-[:of_participant]-(p)<-[:of_diagnosis]-(dg:diagnosis)
with st, num_p, dg.diagnosis_classification as dg_cancers, count(dg.diagnosis_classification) as num_cancers, count(dg.id) as count_of_diag
ORDER BY num_cancers desc
with st, num_p, collect(dg_cancers + ' (' + toString(num_cancers) + ')') as cancers, sum(count_of_diag) as num_of_diag
MATCH (st)<-[*..5]-(fl)
WHERE (fl:clinical_measure_file OR fl: sequencing_file OR fl:pathology_file OR fl:radiology_file OR fl:methylation_array_file OR fl:single_cell_sequencing_file OR fl:cytogenomic_file)
with st, num_p, cancers, fl.file_type as ft, count(fl.file_type) as num_ft, num_of_diag
ORDER BY num_ft desc
with st, num_p, cancers, collect(ft + ' (' + toString(num_ft) + ')') as file_types, sum(num_ft) as num_files, num_of_diag
OPTIONAL MATCH (st)<-[:of_participant|of_cell_line|of_pdx]-(pcp)<-[:of_sample]-(sm1:sample)
WHERE (pcp:participant or pcp:cell_line or pcp:pdx)
WITH st, num_p, cancers, file_types, num_files, count(distinct sm1.sample_id) as num_samples_1, num_of_diag
OPTIONAL MATCH (st)<-[:of_participant]-(participant)<-[:of_sample]-(sm1:sample)<--(cp)<--(sm2:sample)
WHERE (cp:cell_line or cp:pdx)
WITH st, num_p, cancers, file_types, num_files, num_samples_1, count(distinct sm2.sample_id) as num_samples_2, num_of_diag
WITH st, num_p, cancers, file_types, num_files, num_samples_1 + num_samples_2 as num_samples, num_of_diag
RETURN DISTINCT
st.id as id,
st.study_id as study_id,
st.phs_accession as phs_accession,
num_p as num_of_participants,
num_samples as num_of_samples,
num_files as num_of_files,
num_of_diag as num_of_diag