cellmaps-utils 0.6.0__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/HISTORY.rst +7 -0
  2. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/PKG-INFO +8 -1
  3. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils/__init__.py +1 -1
  4. cellmaps_utils-0.7.0/cellmaps_utils/hierdiff.py +142 -0
  5. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils.egg-info/PKG-INFO +8 -1
  6. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils.egg-info/SOURCES.txt +8 -0
  7. cellmaps_utils-0.7.0/docs/cm4ai_data_release.rst +273 -0
  8. cellmaps_utils-0.7.0/docs/cx2_to_hcx_conversion.rst +84 -0
  9. cellmaps_utils-0.7.0/docs/ddot_converters.rst +102 -0
  10. cellmaps_utils-0.7.0/docs/hidef_converters.rst +61 -0
  11. cellmaps_utils-0.7.0/docs/hierarchical_networks.rst +21 -0
  12. cellmaps_utils-0.7.0/docs/hierarchy_robustness.rst +116 -0
  13. cellmaps_utils-0.7.0/docs/in_project.rst +217 -0
  14. cellmaps_utils-0.7.0/docs/upload_to_ndex.rst +83 -0
  15. cellmaps_utils-0.7.0/docs/usage.rst +12 -0
  16. cellmaps_utils-0.6.0/cellmaps_utils/hierdiff.py +0 -81
  17. cellmaps_utils-0.6.0/docs/usage.rst +0 -787
  18. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/AUTHORS.rst +0 -0
  19. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/CONTRIBUTING.rst +0 -0
  20. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/LICENSE +0 -0
  21. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/MANIFEST.in +0 -0
  22. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/README.rst +0 -0
  23. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils/apms_readme.txt +0 -0
  24. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils/apmstool.py +0 -0
  25. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils/basecmdtool.py +0 -0
  26. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils/cellmaps_utilscmd.py +0 -0
  27. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils/constants.py +0 -0
  28. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils/crispr_readme.txt +0 -0
  29. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils/crisprtool.py +0 -0
  30. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils/ddotconverter.py +0 -0
  31. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils/exceptions.py +0 -0
  32. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils/hcx_utils.py +0 -0
  33. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils/hidefconverter.py +0 -0
  34. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils/ifimage_readme.txt +0 -0
  35. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils/iftool.py +0 -0
  36. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils/logutils.py +0 -0
  37. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils/music_utils.py +0 -0
  38. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils/ndexupload.py +0 -0
  39. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils/provenance.py +0 -0
  40. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils/tabletool.py +0 -0
  41. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils.egg-info/dependency_links.txt +0 -0
  42. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils.egg-info/not-zip-safe +0 -0
  43. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils.egg-info/requires.txt +0 -0
  44. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/cellmaps_utils.egg-info/top_level.txt +0 -0
  45. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/docs/Makefile +0 -0
  46. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/docs/_build/html/_static/file.png +0 -0
  47. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/docs/_build/html/_static/minus.png +0 -0
  48. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/docs/_build/html/_static/plus.png +0 -0
  49. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/docs/authors.rst +0 -0
  50. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/docs/cellmaps_utils.rst +0 -0
  51. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/docs/conf.py +0 -0
  52. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/docs/contributing.rst +0 -0
  53. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/docs/devbranches.rst +0 -0
  54. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/docs/developer.rst +0 -0
  55. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/docs/history.rst +0 -0
  56. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/docs/index.rst +0 -0
  57. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/docs/installation.rst +0 -0
  58. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/docs/integrationtesting.rst +0 -0
  59. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/docs/make.bat +0 -0
  60. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/docs/modules.rst +0 -0
  61. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/docs/newrelease.rst +0 -0
  62. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/docs/outputs.rst +0 -0
  63. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/docs/pypircfile.rst +0 -0
  64. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/docs/versioningscheme.rst +0 -0
  65. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/setup.cfg +0 -0
  66. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/setup.py +0 -0
  67. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/.DS_Store +0 -0
  68. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/__init__.py +0 -0
  69. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/data/ddot_output.ont +0 -0
  70. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/data/hidef_output.edges +0 -0
  71. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/data/hidef_output.nodes +0 -0
  72. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/data/images/blue.jpg +0 -0
  73. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/data/images/green.jpg +0 -0
  74. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/data/images/red.jpg +0 -0
  75. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/data/images/yellow.jpg +0 -0
  76. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/data/parent_edgelist +0 -0
  77. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/data/reactome_ddot.txt +0 -0
  78. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/data/ro-crate-metadata.json +0 -0
  79. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/data/test_password +0 -0
  80. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/test_apmstool.py +0 -0
  81. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/test_basecommandlinetool.py +0 -0
  82. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/test_crisprtool.py +0 -0
  83. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/test_ddotconverter.py +0 -0
  84. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/test_helloworldcommand.py +0 -0
  85. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/test_hidefconverter.py +0 -0
  86. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/test_iftool.py +0 -0
  87. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/test_integation_provenance.py +0 -0
  88. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/test_logutils.py +0 -0
  89. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/test_ndexupload.py +0 -0
  90. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/test_provenance.py +0 -0
  91. {cellmaps_utils-0.6.0 → cellmaps_utils-0.7.0}/tests/test_tabletool.py +0 -0
@@ -2,6 +2,13 @@
2
2
  History
3
3
  =======
4
4
 
5
+ 0.7.0 (2025-03-05)
6
+ ------------------
7
+
8
+ * Add ``compute_hierarchy_robustness`` method to ``HierarchyDiff`` class to assess the robustness of a hierarchy
9
+ based on Jaccard similarity across multiple alternative hierarchies.
10
+
11
+
5
12
  0.6.0 (2025-02-05)
6
13
  ------------------
7
14
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cellmaps_utils
3
- Version: 0.6.0
3
+ Version: 0.7.0
4
4
  Summary: Contains utilities needed by Cell Maps tools
5
5
  Home-page: https://github.com/idekerlab/cellmaps_utils
6
6
  Author: Cell Maps team
@@ -145,6 +145,13 @@ This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypack
145
145
  History
146
146
  =======
147
147
 
148
+ 0.7.0 (2025-03-05)
149
+ ------------------
150
+
151
+ * Add ``compute_hierarchy_robustness`` method to ``HierarchyDiff`` class to assess the robustness of a hierarchy
152
+ based on Jaccard similarity across multiple alternative hierarchies.
153
+
154
+
148
155
  0.6.0 (2025-02-05)
149
156
  ------------------
150
157
 
@@ -4,6 +4,6 @@
4
4
 
5
5
  __author__ = 'Cell Maps team'
6
6
  __email__ = 'tools@cm4ai.org'
7
- __version__ = '0.6.0'
7
+ __version__ = '0.7.0'
8
8
  __repo_url__ = 'https://github.com/idekerlab/cellmaps_utils'
9
9
  __description__ = 'Contains utilities needed by Cell Maps tools'
@@ -0,0 +1,142 @@
1
+ import logging
2
+
3
+ import numpy as np
4
+ import pandas as pd
5
+ from ndex2.cx2 import RawCX2NetworkFactory, CX2Network
6
+
7
+ logger = logging.getLogger(__name__)
8
+
9
+
10
+ class HierarchyDiff:
11
+ """
12
+ A class to compare two hierarchies in CX2 (HCX)
13
+ """
14
+
15
+ def __init__(self):
16
+ """
17
+ Constructor
18
+ """
19
+ pass
20
+
21
+ @staticmethod
22
+ def _calculate_jaccard(setA, setB):
23
+ """
24
+ Calculate the Jaccard similarity between two sets.
25
+
26
+ The Jaccard similarity is defined as |A ∩ B| / |A ∪ B|.
27
+
28
+ :param setA: First set.
29
+ :type setA: set
30
+ :param setB: Second set.
31
+ :type setB: set
32
+ :return: The Jaccard similarity index.
33
+ :rtype: float
34
+ """
35
+ overlap = len(setA.intersection(setB))
36
+ union = len(setA.union(setB))
37
+ return overlap / union if union > 0 else 0
38
+
39
+ def _hierarchy_overlap(self, ref_hierarchy, alt_hierarchy):
40
+ """
41
+ Computes a Jaccard similarity between nodes in two CX2Network hierarchies.
42
+ For each node in the alternative hierarchy, it calculates the Jaccard index with each node in
43
+ the reference hierarchy.
44
+
45
+ :param ref_hierarchy: The reference hierarchy to compare against.
46
+ :type ref_hierarchy: ndex2.cx2.CX2Network
47
+ :param alt_hierarchy: The alternative hierarchy being compared.
48
+ :type alt_hierarchy: ndex2.cx2.CX2Network
49
+ :return: A DataFrame of pass/fail (1/0) based on Jaccard similarity.
50
+ :rtype: pandas.DataFrame
51
+ """
52
+ ref_nodes = ref_hierarchy.get_nodes()
53
+ nodes = alt_hierarchy.get_nodes()
54
+
55
+ # Prepare a DataFrame to hold JI values
56
+ ji_df = pd.DataFrame(index=list(nodes.keys()), columns=list(ref_nodes.keys()), dtype=float)
57
+
58
+ for node_id, node_obj in nodes.items():
59
+ ont_comp_genes = set(node_obj.get('v', {}).get('CD_MemberList', '').split())
60
+ for ref_node_id, ref_node_obj in ref_nodes.items():
61
+ comp_genes = set(ref_node_obj.get('v', {}).get('CD_MemberList', '').split())
62
+ ji_df.at[node_id, ref_node_id] = self._calculate_jaccard(ont_comp_genes, comp_genes) \
63
+ if ont_comp_genes and comp_genes else 0
64
+
65
+ return ji_df
66
+
67
+ def compute_hierarchy_robustness(self, ref_hierarchy, alt_hierarchies, ji_thre=0.4):
68
+ """
69
+ Computes a robustness score for each node in a reference hierarchy based on its structural overlap
70
+ across multiple alternative hierarchies. The overlap is measured using the Jaccard Index (JI),
71
+ and a threshold that determines if a node is considered to have sufficient overlap in a given
72
+ alternative hierarchy (values above the threshold are set to 1, while values below are set to 0).
73
+ The higher the overlap across the alternative hierarchies, the higher the robustness score.
74
+
75
+ robustness = (# hierarchies where JI > ji_thre) / (total number of alternative hierarchies)
76
+
77
+ :param ref_hierarchy: The reference hierarchy whose nodes' robustness is computed.
78
+ :type ref_hierarchy: ndex2.cx2.CX2Network or dict (raw CX2)
79
+ :param alt_hierarchies: A list of alternative hierarchies to compare against.
80
+ :type alt_hierarchies: list[ndex2.cx2.CX2Network or dict]
81
+ :param ji_thre: The Jaccard threshold used to determine overlap.
82
+ :type ji_thre: float
83
+ :return: The reference hierarchy with an added 'robustness' attribute for each node.
84
+ :rtype: ndex2.cx2.CX2Network
85
+ """
86
+ factory = RawCX2NetworkFactory()
87
+ ref_hier = ref_hierarchy if isinstance(ref_hierarchy, CX2Network) else factory.get_cx2network(ref_hierarchy)
88
+ alt_hiers = []
89
+ for hier in alt_hierarchies:
90
+ alt_hiers.append(hier if isinstance(hier, CX2Network) else factory.get_cx2network(hier))
91
+ r_hier = pd.DataFrame(index=list(ref_hier.get_nodes().keys()))
92
+ r_hier['robustness'] = [0] * len(r_hier)
93
+ for hierarchy in alt_hiers:
94
+ ji_df = self._hierarchy_overlap(ref_hier, hierarchy)
95
+ # Make a "pass/fail" matrix: 0 if JI <= threshold, 1 otherwise
96
+ pass_fail_df = (ji_df > ji_thre).astype(int)
97
+ maxs = pass_fail_df.max(axis=0)
98
+ r_hier.loc[pass_fail_df.columns, 'robustness'] += np.array(maxs).astype(int)
99
+ r_hier['robustness'] /= len(alt_hiers)
100
+ for node_id, robustness in r_hier['robustness'].to_dict().items():
101
+ ref_hier.add_node_attribute(node_id, 'robustness', robustness)
102
+
103
+ return ref_hier
104
+
105
+ def compare_hierarchies(self, hierarchy_a=None, hierarchy_b=None):
106
+ """
107
+ Compare two hierarchies in CX2 format by calculating Jaccard overlaps and
108
+ assigning a 'robustness' (overlap) score to each node in the first hierarchy.
109
+
110
+ :param hierarchy_a: The first (reference) hierarchy to compare.
111
+ :type hierarchy_a: ndex2.cx2.CX2Network
112
+ :param hierarchy_b: The second (alternative) hierarchy to compare against.
113
+ :type hierarchy_b: ndex2.cx2.CX2Network
114
+ :return: The first hierarchy with an added 'robustness' node attribute.
115
+ :rtype: ndex2.cx2.CX2Network
116
+ """
117
+ ji_df = self._hierarchy_overlap(hierarchy_a, hierarchy_b)
118
+ maxs = ji_df.max(axis=0)
119
+ node_overlap_scores = maxs.to_dict()
120
+
121
+ # Add nodes annotate nodes in hierarchy_a robustness scores
122
+ for node_id, data in hierarchy_a.get_nodes().items():
123
+ score = node_overlap_scores.get(node_id, 0)
124
+ hierarchy_a.add_node_attribute(node_id, 'robustness', score)
125
+
126
+ return hierarchy_a
127
+
128
+ def compare_hierarchies_from_files(self, hierarchy_a_path=None, hierarchy_b_path=None):
129
+ """
130
+ Compare two hierarchies from files then calculating overlap-based scores.
131
+
132
+ :param hierarchy_a_path: Path to the first (reference) hierarchy file.
133
+ :type hierarchy_a_path: str
134
+ :param hierarchy_b_path: Path to the second (alternative) hierarchy file.
135
+ :type hierarchy_b_path: str
136
+ :return: The first hierarchy (from hierarchy_a_path) with added robustness scores.
137
+ :rtype: ndex2.cx2.CX2Network
138
+ """
139
+ factory = RawCX2NetworkFactory()
140
+ hierarchy_a = factory.get_cx2network(hierarchy_a_path)
141
+ hierarchy_b = factory.get_cx2network(hierarchy_b_path)
142
+ return self.compare_hierarchies(hierarchy_a, hierarchy_b)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cellmaps_utils
3
- Version: 0.6.0
3
+ Version: 0.7.0
4
4
  Summary: Contains utilities needed by Cell Maps tools
5
5
  Home-page: https://github.com/idekerlab/cellmaps_utils
6
6
  Author: Cell Maps team
@@ -145,6 +145,13 @@ This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypack
145
145
  History
146
146
  =======
147
147
 
148
+ 0.7.0 (2025-03-05)
149
+ ------------------
150
+
151
+ * Add ``compute_hierarchy_robustness`` method to ``HierarchyDiff`` class to assess the robustness of a hierarchy
152
+ based on Jaccard similarity across multiple alternative hierarchies.
153
+
154
+
148
155
  0.6.0 (2025-02-05)
149
156
  ------------------
150
157
 
@@ -35,11 +35,18 @@ cellmaps_utils.egg-info/top_level.txt
35
35
  docs/Makefile
36
36
  docs/authors.rst
37
37
  docs/cellmaps_utils.rst
38
+ docs/cm4ai_data_release.rst
38
39
  docs/conf.py
39
40
  docs/contributing.rst
41
+ docs/cx2_to_hcx_conversion.rst
42
+ docs/ddot_converters.rst
40
43
  docs/devbranches.rst
41
44
  docs/developer.rst
45
+ docs/hidef_converters.rst
46
+ docs/hierarchical_networks.rst
47
+ docs/hierarchy_robustness.rst
42
48
  docs/history.rst
49
+ docs/in_project.rst
43
50
  docs/index.rst
44
51
  docs/installation.rst
45
52
  docs/integrationtesting.rst
@@ -48,6 +55,7 @@ docs/modules.rst
48
55
  docs/newrelease.rst
49
56
  docs/outputs.rst
50
57
  docs/pypircfile.rst
58
+ docs/upload_to_ndex.rst
51
59
  docs/usage.rst
52
60
  docs/versioningscheme.rst
53
61
  docs/_build/html/_static/file.png
@@ -0,0 +1,273 @@
1
+ Cell Maps for AI Data Release
2
+ ------------------------------
3
+
4
+ This section describes how to generate a new `CM4AI`_ data release. The
5
+ intended audience is for data generation sites and anyone interested in knowing
6
+ how the datasets on `CM4AI`_ site are created.
7
+
8
+ There are four steps to the data release:
9
+
10
+ 1) Each individual dataset must be run through ``cellmaps_utilscmd.py XX``
11
+ command to generate `RO-Crate`_ directories.
12
+
13
+ 2) These `RO-Crate`_ directories must be compressed
14
+
15
+ 3) ``cellmaps_utilscmd.py rocratetable`` must be given these compressed `RO-Crate`_ files to generate table
16
+
17
+ 4) Compressed `RO-Crate`_ files must be uploaded to `CM4AI`_
18
+
19
+ 5) The table generated must be sent to admin of `CM4AI`_ site so they can load it and
20
+ display the new data release
21
+
22
+
23
+ 1) Perturbation/CRISPR data release (step 1 above)
24
+ ===================================================
25
+
26
+ The command line tool ``cellmaps_utilscmd.py crisprconverter`` takes a `h5ad`_ file
27
+ and copies that file along with other meta data files into a `RO-Crate`_ suitable
28
+ for persistance to `FAIRSCAPE`_ and ultimately publication on `CM4AI`_
29
+
30
+ The example below generates a `RO-Crate`_ directory under the ``0.1alpha`` folder using
31
+ `h5ad`_ file named ``foo.h5ad`` passed in via the ``--h5ad`` flag
32
+
33
+ .. code-block::
34
+
35
+ echo "completely fake h5ad file" > foo.h5ad
36
+
37
+ cellmaps_utilscmd.py -vv crisprconverter 0.1alpha --h5ad foo.h5ad --author 'Mali Lab' \
38
+ --name 'CRISPR' --organization_name 'Mali Lab' \
39
+ --project_name CM4AI --release '0.1 alpha' --treatment untreated \
40
+ --dataset 4channel --cell_line KOLF2.1J --gene_set chromatin \
41
+ --tissue undifferentiated --num_perturb_guides 6 \
42
+ --num_non_target_ctrls 109 --num_screen_targets 108
43
+
44
+
45
+ Example contents generated by above command:
46
+
47
+ .. code-block::
48
+
49
+ 0.1alpha/
50
+ └── cm4ai_chromatin_kolf2.1j_undifferentiated_untreated_crispr_4channel_0.1_alpha
51
+ ├── perturbation.h5ad
52
+ ├── dataset_info.json
53
+ ├── readme.txt
54
+ └── ro-crate-metadata.json
55
+
56
+ .. note::
57
+
58
+ Invoke ``cellmaps_utilscmd.py crisperconverter -h`` for usage information
59
+
60
+ .. warning::
61
+
62
+ This tool does not currently validate .h5ad, but when it does the above example
63
+ will fail
64
+
65
+ 1) Affinity Purification Mass Spectrometry (AP-MS) data release
66
+ ============================================================================
67
+
68
+ The command line tool ``cellmaps_utilscmd.py apmsconverter`` consumes one or more `tsv`_ files
69
+ that are combined and stored into a `RO-Crate`_ suitable
70
+ for persistance to `FAIRSCAPE`_ and ultimately publication on `CM4AI`_
71
+
72
+ The example below generates a `RO-Crate`_ directory under the ``0.1alpha`` folder using
73
+ `tsv`_ file named ``DNMT3A.tsv`` that is passed in via the ``--inputs`` flag
74
+
75
+
76
+ .. code-block::
77
+
78
+ echo -ne 'Bait\tPrey\tPreyGene.x\tSpec\tSpecSum\tAvgSpec\tNumReplicates.x\t' > DNMT3A.tsv
79
+ echo -ne 'ctrlCounts\tAvgP.x\tMaxP.x\tTopoAvgP.x\tTopoMaxP.x\tSaintScore.x\t' >> DNMT3A.tsv
80
+ echo -e 'logOddsScore\tFoldChange.x\tBFDR.x\tboosted_by.x' >> DNMT3A.tsv
81
+ echo -ne 'DNMT3A\tO00422\tSAP18_HUMAN\t6|7|8|10\t31\t7.75\t4\t0|0|0|0|0|0|0|0\t' >> DNMT3A.tsv
82
+ echo -e '1\t1\t1\t1\t1\t13.51\t77.5\t0\tNA' >> DNMT3A.tsv
83
+ echo -ne 'DNMT3A\tO00571\tDDX3X_HUMAN\t3|7|11|9\t30\t7.5\t4\t0|1|3|3|0|0|0|0\t' >> DNMT3A.tsv
84
+ echo -e '0.99\t1\t0.99\t1\t0.99\t3.63\t8.57\t0\tNA' >> DNMT3A.tsv
85
+
86
+ cellmaps_utilscmd.py apmsconverter 0.1alpha --inputs DNMT3A.tsv \
87
+ --author 'Krogan Lab' --name 'AP-MS' \
88
+ --organization_name 'Krogan Lab' --project_name 'CM4AI' \
89
+ --release '0.1 alpha' --treatment untreated \
90
+ --cell_line 'MDA-MB-468' --gene_set 'chromatin'
91
+
92
+ Example contents generated by above command:
93
+
94
+ .. code-block::
95
+
96
+ 0.1alpha/
97
+ └── cm4ai_chromatin_mda-mb-468_untreated_apms_0.1_alpha
98
+ ├── apms.tsv
99
+ ├── dataset_info.json
100
+ ├── readme.txt
101
+ └── ro-crate-metadata.json
102
+
103
+ .. note::
104
+
105
+ Invoke ``cellmaps_utilscmd.py apmsconverter -h`` for usage information
106
+
107
+
108
+ 1) Size Exclusion Chromatography with Mass Spectrometry (SEC-MS) data release
109
+ ==========================================================================================
110
+
111
+ TODO
112
+
113
+
114
+ 1) Immunofluorescent Image (IFImage) data release
115
+ ==================================================================
116
+
117
+ The command line tool ``cellmaps_utilscmd.py ifconverter`` consumes a `csv`_ file
118
+ that contains image links and other information to download and stored into a `RO-Crate`_ suitable
119
+ for persistance to `FAIRSCAPE`_ and ultimately publication on `CM4AI`_
120
+
121
+ The example below generates a `RO-Crate`_ directory under the ``0.1alpha`` folder using
122
+ `csv`_ file named ``example.csv`` that is passed in via the ``--inputs`` flag
123
+
124
+
125
+ .. code-block::
126
+
127
+ # be sure to download this file: https://github.com/idekerlab/cellmaps_utils/raw/main/examples/iftool/example.csv
128
+ # and name it example.csv
129
+ wget https://github.com/idekerlab/cellmaps_utils/raw/main/examples/iftool/example.csv
130
+
131
+ cellmaps_utilscmd.py ifconverter 0.1alpha --input example.csv \
132
+ --author 'Lundberg Lab' --name 'IF images' \
133
+ --organization_name 'Lundberg Lab' --project_name 'CM4AI' \
134
+ --release '0.1 alpha' --treatment paclitaxel \
135
+ --cell_line 'MDA-MB-468' --gene_set 'chromatin'
136
+
137
+ Example contents generated by above command:
138
+
139
+ .. code-block::
140
+
141
+ 0.1alpha/
142
+ └── cm4ai_chromatin_mda-mb-468_paclitaxel_ifimage_0.1_alpha
143
+ ├── antibody_gene_table.tsv
144
+ ├── blue
145
+ │   └── B2AI_1_Paclitaxel_C1_R1_z01_blue.jpg
146
+ ├── dataset_info.json
147
+ ├── green
148
+ │   └── B2AI_1_Paclitaxel_C1_R1_z01_green.jpg
149
+ ├── readme.txt
150
+ ├── red
151
+ │   └── B2AI_1_Paclitaxel_C1_R1_z01_red.jpg
152
+ ├── ro-crate-metadata.json
153
+ └── yellow
154
+ └── B2AI_1_Paclitaxel_C1_R1_z01_yellow.jpg
155
+
156
+ .. note::
157
+
158
+ Invoke ``cellmaps_utilscmd.py ifconverter -h`` for usage information
159
+
160
+ 2) Compress `RO-Crate`_ from step one
161
+ =========================================
162
+
163
+ In this step the `RO-Crate`_ directories are compressed into files.
164
+
165
+ .. note::
166
+
167
+ The code fragment below assumes all `RO-Crate`_ directories were put into ``0.1alpha``
168
+ directory.
169
+
170
+ .. code-block::
171
+
172
+ # assuming all RO-Crates above were put into 0.1alpha directory
173
+ cd 0.1alpha
174
+
175
+ for Y in `find . -name "*_*" -maxdepth 1 -type d` ; do
176
+ echo $Y
177
+ tar -cz $Y > ${Y}.tar.gz
178
+ done
179
+
180
+ If examples above were run then the ``0.1alpha`` directory will look like this:
181
+
182
+ .. code-block::
183
+
184
+ .
185
+ ├── cm4ai_chromatin_kolf2.1j_undifferentiated_untreated_crispr_4channel_0.1_alpha
186
+ ├── cm4ai_chromatin_kolf2.1j_undifferentiated_untreated_crispr_4channel_0.1_alpha.tar.gz
187
+ ├── cm4ai_chromatin_mda-mb-468_paclitaxel_ifimage_0.1_alpha
188
+ ├── cm4ai_chromatin_mda-mb-468_paclitaxel_ifimage_0.1_alpha.tar.gz
189
+ ├── cm4ai_chromatin_mda-mb-468_untreated_apms_0.1_alpha
190
+ └── cm4ai_chromatin_mda-mb-468_untreated_apms_0.1_alpha.tar.gz
191
+
192
+ 3) Run ``cellmaps_utilscmd.py rocratetable`` on `RO-Crate`_ files
193
+ ===================================================================
194
+
195
+ In this step, the `RO-Crate`_ files are examined and a table is generated
196
+ that can be sent to the `CM4AI`_ site admin to show the new data release
197
+
198
+ .. note::
199
+
200
+ The code fragment below assumes all `RO-Crate`_ directories were put into ``0.1alpha``
201
+ directory.
202
+
203
+ .. code-block::
204
+
205
+ # assuming all RO-Crates above were put into 0.1alpha directory
206
+ # along with gzip files
207
+
208
+ cd 0.1alpha
209
+
210
+ cellmaps_utilscmd.py rocratetable table --downloadurlprefix 'https://cm4ai.org/Data/' --rocrates `/bin/ls | grep -v ".gz"`
211
+
212
+
213
+ The above command will create a directory named ``table`` and within that directory
214
+ will be a `tsv`_ file named ``data.tsv``
215
+
216
+ .. code-block::
217
+
218
+ table
219
+ └── data.tsv
220
+
221
+
222
+ Contents of `tsv`_ ``data.tsv`` file:
223
+
224
+ .. code-block::
225
+
226
+ FAIRSCAPE ARK ID Date Version Type Cell Line Tissue Treatment Gene set Generated By Software Name Description KeywordDownload RO-Crate Data Package Download RO-Crate Data Package Size MB Generated By Software Output Dataset Responsible Lab
227
+ d4d80b1d-8d49-4204-8c0d-209c5b9ccdf2:cm4ai_chromatin_kolf2.1j_undifferentiated_untreated_crispr_4channel_0.1_alpha 2024-04-29 0.1 alpha Data KOLF2.1J undifferentiated untreated chromatin CRISPR CM4AI 0.1 alpha KOLF2.1J untreated CRISPR undifferentiated 4channel chromatin CM4AI,0.1 alpha,KOLF2.1J,untreated,CRISPR,undifferentiated,4channel,chromatin https://cm4ai.org/Data/cm4ai_chromatin_kolf2.1j_undifferentiated_untreated_crispr_4channel_0.1_alpha.tar.gz 1 Mali Lab
228
+ 134e01c8-90ea-457d-9e6e-ca046ecc860f:cm4ai_chromatin_mda-mb-468_paclitaxel_ifimage_0.1_alpha 2024-04-29 0.1 alpha Data MDA-MB-468 breast; mammary gland paclitaxel chromatin IF images CM4AI 0.1 alpha MDA-MB-468 paclitaxel IF microscopy images breast; mammary gland chromatin CM4AI,0.1 alpha,MDA-MB-468,paclitaxel,IF microscopy,images,breast; mammary gland,chromatin https://cm4ai.org/Data/cm4ai_chromatin_mda-mb-468_paclitaxel_ifimage_0.1_alpha.tar.gz 1 Lundberg Lab
229
+ 7240c7d7-327c-423c-834d-1e99ab8a417b:cm4ai_chromatin_mda-mb-468_untreated_apms_0.1_alpha 2024-04-29 0.1 alpha Data MDA-MB-468 breast; mammary gland untreated chromatin AP-MS CM4AI 0.1 alpha MDA-MB-468 untreated breast; mammary gland AP-MS edgelist chromatin CM4AI,0.1 alpha,MDA-MB-468,untreated,breast; mammary gland,AP-MS edgelist,chromatin https://cm4ai.org/Data/cm4ai_chromatin_mda-mb-468_untreated_apms_0.1_alpha.tar.gz 1 Krogan Lab
230
+
231
+ .. note::
232
+
233
+ ``cellmaps_utilscmd.py rocratetable`` runs way faster if the uncompressed
234
+ `RO-Crate`_ directories are passed in. The script does need the ``.gz``
235
+ files in the same directory to get file sizes output in the generated
236
+ table.
237
+
238
+
239
+ 4) Upload `RO-Crate`_ files
240
+ =============================
241
+
242
+ For this step the `RO-Crate`_ files ending with ``.gz`` should be uploaded to path matching
243
+ prefix set via ``--downloadurlprefix`` in Step 3
244
+
245
+ .. note::
246
+
247
+ Be sure to verify URLs resolve for uploaded files
248
+
249
+
250
+
251
+ 5) Send table from Step 4 to admin of `CM4AI`_ site
252
+ ======================================================
253
+
254
+ In this step send the ``table/data.tsv`` file to `CM4AI`_ admin
255
+ and let them know if this table is to append or overwrite existing
256
+ data
257
+
258
+
259
+ .. _CM4AI: https://cm4ai.org
260
+ .. _RO-Crate: https://www.researchobject.org/ro-crate
261
+ .. _FAIRSCAPE CLI: https://fairscape.github.io/fairscape-cli
262
+ .. _FAIRSCAPE: https://fairscape.github.io
263
+ .. _software: https://fairscape.github.io/fairscape-cli/getting-started/#register-software-metadata
264
+ .. _dataset: https://fairscape.github.io/fairscape-cli/getting-started/#register-dataset-metadata
265
+ .. _computation: https://fairscape.github.io/fairscape-cli/getting-started/#register-computation-metadata
266
+ .. _tar: https://en.wikipedia.org/wiki/Tar_(computing)
267
+ .. _gzip: https://en.wikipedia.org/wiki/Gzip
268
+ .. _h5ad: https://github.com/scverse/anndata/issues/180
269
+ .. _tsv: https://en.wikipedia.org/wiki/Tab-separated_values
270
+ .. _csv: https://en.wikipedia.org/wiki/Comma-separated_values
271
+ .. _CX2: https://cytoscape.org/cx/cx2/specification/cytoscape-exchange-format-specification-(version-2)
272
+ .. _HCX: https://cytoscape.org/cx/cx2/hcx-specification
273
+ .. _Reference: https://cellmaps-utils.readthedocs.io/en/latest/cellmaps_utils.html#cellmaps-utils-hierdiff-hierarchy-comparison-module
@@ -0,0 +1,84 @@
1
+ CX2 to HCX conversion
2
+ =========================
3
+
4
+ The CX2 to HCX conversion process enhances a CX2 hierarchical network by adding HCX-specific annotations.
5
+ The HCX format is a specialized version of CX2 that enables hierarchical visualization in Cytoscape,
6
+ ensuring that relationships and interactome information are properly structured.
7
+
8
+ Why Convert to HCX?
9
+
10
+ - Enables hierarchical network visualization in Cytoscape.
11
+ - Adds interactome annotations to define relationships.
12
+ - Supports integration with NDEx, allowing retrieval of interactome data.
13
+
14
+ **Example 1: Converting a CX2 Hierarchical Network to HCX**
15
+
16
+ To convert a CX2 hierarchical network into an HCX format, use the ``convert_hierarchical_network_to_hcx`` function:
17
+
18
+ .. code-block::
19
+
20
+ from cellmaps_utils.hcx_utils import convert_hierarchical_network_to_hcx
21
+
22
+ hierarchy_path = "path/to/hierarchy.cx2"
23
+ interactome_url = "https://www.ndexbio.org/network/uuid"
24
+
25
+ hcx_network = convert_hierarchical_network_to_hcx(
26
+ hierarchy=hierarchy_path,
27
+ interactome_url=interactome_url
28
+ )
29
+
30
+ hcx_network.write_as_raw_cx2("path/to/output/hierarchy_hcx.cx2")
31
+
32
+ Expected Output: ``hierarchy_hcx.cx2`` – The HCX hierarchical network, enriched with interactome annotations.
33
+
34
+ .. _Example 2:
35
+
36
+ **Example 2: Converting a CX2 Hierarchy with a Local Interactome**
37
+
38
+ If you have a local interactome file instead of an NDEx link, you can still convert a CX2 hierarchy to HCX:
39
+
40
+ .. code-block::
41
+
42
+ from ndex2.cx2 import RawCX2NetworkFactory
43
+ from cellmaps_utils.hcx_utils import add_hcx_network_annotations, add_hcx_members_annotation, add_isroot_node_attribute, get_root_nodes
44
+
45
+ hierarchy_path = "path/to/hierarchy.cx2"
46
+ interactome_path = "path/to/interactome.cx2"
47
+
48
+ # Load hierarchy network and interactome
49
+ factory = RawCX2NetworkFactory()
50
+ hierarchy = factory.get_cx2network(hierarchy_path)
51
+ interactome = factory.get_cx2network(interactome_path)
52
+
53
+ # Add HCX annotations
54
+ hierarchy = add_hcx_network_annotations(hierarchy, interactome=interactome, outdir='path/to/output/')
55
+
56
+ # Add HCX::members attribute to node attributes
57
+ add_hcx_members_annotation(hierarchy, interactome)
58
+
59
+ # Add isRoot attribute to node attributes
60
+ add_isroot_node_attribute(hierarchy, get_root_nodes(hierarchy))
61
+
62
+ # Save HCX file
63
+ hierarchy.write_as_raw_cx2("path/to/output/hierarchy.cx2")
64
+
65
+ Expected Output (Hierarchy and interactome will be saved in the same directory ``path/to/output/``):
66
+
67
+ - ``hierarchy_hcx.cx2`` – HCX hierarchical network with interactome annotations.
68
+ - ``hierarchy_parent.cx2``
69
+
70
+ .. _CM4AI: https://cm4ai.org
71
+ .. _RO-Crate: https://www.researchobject.org/ro-crate
72
+ .. _FAIRSCAPE CLI: https://fairscape.github.io/fairscape-cli
73
+ .. _FAIRSCAPE: https://fairscape.github.io
74
+ .. _software: https://fairscape.github.io/fairscape-cli/getting-started/#register-software-metadata
75
+ .. _dataset: https://fairscape.github.io/fairscape-cli/getting-started/#register-dataset-metadata
76
+ .. _computation: https://fairscape.github.io/fairscape-cli/getting-started/#register-computation-metadata
77
+ .. _tar: https://en.wikipedia.org/wiki/Tar_(computing)
78
+ .. _gzip: https://en.wikipedia.org/wiki/Gzip
79
+ .. _h5ad: https://github.com/scverse/anndata/issues/180
80
+ .. _tsv: https://en.wikipedia.org/wiki/Tab-separated_values
81
+ .. _csv: https://en.wikipedia.org/wiki/Comma-separated_values
82
+ .. _CX2: https://cytoscape.org/cx/cx2/specification/cytoscape-exchange-format-specification-(version-2)
83
+ .. _HCX: https://cytoscape.org/cx/cx2/hcx-specification
84
+ .. _Reference: https://cellmaps-utils.readthedocs.io/en/latest/cellmaps_utils.html#cellmaps-utils-hierdiff-hierarchy-comparison-module