Skip to content

Commit b6e62aa

Browse files
committed
Update docs
1 parent 8310b42 commit b6e62aa

10 files changed

Lines changed: 207 additions & 110 deletions

README.md

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ It supports GA4GH-oriented formats such as Beacon Friendly Format (`BFF`) and Ph
4141

4242
## What It Does
4343

44-
`Pheno-Ranker` turns hierarchical records into comparable binary vectors and computes pairwise similarity or distance metrics.
44+
`Pheno-Ranker` turns hierarchical records into comparable one-hot encoded binary vectors. It then computes pairwise similarity or distance metrics for cohort exploration, patient matching, clustering, multidimensional scaling, and graph analytics.
4545

4646
Main workflows:
4747

4848
- **Cohort mode**: compare every individual or record against every other record in one or more cohorts.
4949
- **Patient mode**: rank records in a reference cohort against a target patient or object.
5050
- **Generic JSON mode**: compare arbitrary categorical JSON data using a configuration file.
51-
- **Precomputed mode**: reuse exported reference-cohort vectors for faster repeated patient matching.
51+
- **Utility workflows**: simulate BFF/PXF data, convert CSV data for ranking, plot summary statistics, and encode vectors as QR codes.
5252

5353
## Quick Start
5454

@@ -70,16 +70,10 @@ Generic JSON with a custom configuration:
7070
pheno-ranker -r movies.json --config movies_config.yaml --include-terms genre year
7171
```
7272

73-
Sparse Matrix Market output for large cohorts:
73+
Cytoscape-compatible graph export:
7474

7575
```bash
76-
pheno-ranker -r individuals.json --matrix-format mtx -o matrix.mtx
77-
```
78-
79-
Cytoscape-compatible graph export with edge filtering:
80-
81-
```bash
82-
pheno-ranker -r individuals.json --cytoscape-json graph.json --graph-max-weight 10
76+
pheno-ranker -r individuals.json --cytoscape-json graph.json
8377
```
8478

8579
## Selected Features
@@ -88,23 +82,23 @@ pheno-ranker -r individuals.json --cytoscape-json graph.json --graph-max-weight
8882
- Generic JSON support through YAML/JSON configuration files.
8983
- Cohort and patient-ranking modes.
9084
- Hamming distance and Jaccard similarity.
91-
- Optional weighted comparisons.
92-
- Export of intermediate hashes and coverage statistics.
93-
- Sparse Matrix Market (`mtx`) output for large matrix workflows.
94-
- Direct Cytoscape-compatible graph export with edge thresholds.
85+
- Patient-mode Z-scores and p-values for match significance.
86+
- Include/exclude term filters, optional variable weights, and HPO ascendant expansion.
87+
- Export of binary vectors, intermediate hashes, alignments, and coverage statistics.
88+
- Outputs suitable for clustering, multidimensional scaling, and graph analytics.
9589
- QR-code utilities for compact encoded vector exchange.
96-
- Companion utilities for CSV import and BFF/PXF simulation.
90+
- Companion utilities for CSV import, BFF/PXF simulation, and summary-statistics plotting.
9791

9892
## Output Formats
9993

10094
Common outputs include:
10195

10296
- `matrix.txt`: dense pairwise comparison matrix.
103-
- `matrix.mtx`: sparse Matrix Market output when `--matrix-format mtx` is used.
10497
- `rank.txt`: patient-mode ranking output.
10598
- `graph.json`: Cytoscape-compatible graph output.
10699
- `graph_stats.txt`: graph summary statistics.
107100
- `export.*.json`: intermediate files for inspection or precomputed workflows.
101+
- `matrix.mtx`: optional sparse Matrix Market output for large matrix workflows.
108102

109103
## Installation
110104

README.md.template

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ It supports GA4GH-oriented formats such as Beacon Friendly Format (`BFF`) and Ph
4141

4242
## What It Does
4343

44-
`Pheno-Ranker` turns hierarchical records into comparable binary vectors and computes pairwise similarity or distance metrics.
44+
`Pheno-Ranker` turns hierarchical records into comparable one-hot encoded binary vectors. It then computes pairwise similarity or distance metrics for cohort exploration, patient matching, clustering, multidimensional scaling, and graph analytics.
4545

4646
Main workflows:
4747

4848
- **Cohort mode**: compare every individual or record against every other record in one or more cohorts.
4949
- **Patient mode**: rank records in a reference cohort against a target patient or object.
5050
- **Generic JSON mode**: compare arbitrary categorical JSON data using a configuration file.
51-
- **Precomputed mode**: reuse exported reference-cohort vectors for faster repeated patient matching.
51+
- **Utility workflows**: simulate BFF/PXF data, convert CSV data for ranking, plot summary statistics, and encode vectors as QR codes.
5252

5353
## Quick Start
5454

@@ -70,16 +70,10 @@ Generic JSON with a custom configuration:
7070
pheno-ranker -r movies.json --config movies_config.yaml --include-terms genre year
7171
```
7272

73-
Sparse Matrix Market output for large cohorts:
73+
Cytoscape-compatible graph export:
7474

7575
```bash
76-
pheno-ranker -r individuals.json --matrix-format mtx -o matrix.mtx
77-
```
78-
79-
Cytoscape-compatible graph export with edge filtering:
80-
81-
```bash
82-
pheno-ranker -r individuals.json --cytoscape-json graph.json --graph-max-weight 10
76+
pheno-ranker -r individuals.json --cytoscape-json graph.json
8377
```
8478

8579
## Selected Features
@@ -88,23 +82,23 @@ pheno-ranker -r individuals.json --cytoscape-json graph.json --graph-max-weight
8882
- Generic JSON support through YAML/JSON configuration files.
8983
- Cohort and patient-ranking modes.
9084
- Hamming distance and Jaccard similarity.
91-
- Optional weighted comparisons.
92-
- Export of intermediate hashes and coverage statistics.
93-
- Sparse Matrix Market (`mtx`) output for large matrix workflows.
94-
- Direct Cytoscape-compatible graph export with edge thresholds.
85+
- Patient-mode Z-scores and p-values for match significance.
86+
- Include/exclude term filters, optional variable weights, and HPO ascendant expansion.
87+
- Export of binary vectors, intermediate hashes, alignments, and coverage statistics.
88+
- Outputs suitable for clustering, multidimensional scaling, and graph analytics.
9589
- QR-code utilities for compact encoded vector exchange.
96-
- Companion utilities for CSV import and BFF/PXF simulation.
90+
- Companion utilities for CSV import, BFF/PXF simulation, and summary-statistics plotting.
9791

9892
## Output Formats
9993

10094
Common outputs include:
10195

10296
- `matrix.txt`: dense pairwise comparison matrix.
103-
- `matrix.mtx`: sparse Matrix Market output when `--matrix-format mtx` is used.
10497
- `rank.txt`: patient-mode ranking output.
10598
- `graph.json`: Cytoscape-compatible graph output.
10699
- `graph_stats.txt`: graph summary statistics.
107100
- `export.*.json`: intermediate files for inspection or precomputed workflows.
101+
- `matrix.mtx`: optional sparse Matrix Market output for large matrix workflows.
108102

109103
## Installation
110104

docs/algorithm.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Note that the flattened keys maintain the original hierarchical relationships of
7676

7777
## Step 2: Generate global hash for reference cohort(s)
7878

79-
We generate a global hash for the reference cohort(s) by utilizing the unique variable entries. The size of the hash depends on the number of variables present in the cohort. The algorithm is optimized to handle a large number of variables, even exceeding 100K (e.g., when considering genomic variation data such as SNPs). To address any potential limitations, the algorithm allows selecting a randomly subset of N random variables from the total available (with the flag `--max-number-var`).
79+
We generate a global hash for the reference cohort(s) by utilizing the unique variable entries. The size of the hash depends on the number of variables present in the cohort. The algorithm is optimized to handle a large number of variables, even exceeding 100K (e.g., when considering genomic variation data such as SNPs). To address any potential limitations, the algorithm allows selecting a random subset of N variables from the total available with `--max-number-vars`.
8080

8181
```json
8282
{
@@ -104,4 +104,4 @@ When working with a target patient's data from a JSON file, it is flattened usin
104104

105105
## Step 5: Compute metrics
106106

107-
Compute differents metrics depending on _cohort_ or _target_ mode.
107+
Compute different metrics depending on _cohort_ or _target_ mode.

docs/cohort.md

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
_Cohort mode_ performs a **cross-comparison** of all individuals in a cohort(s) using as a metric the [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) or the [Jaccard index](https://en.wikipedia.org/wiki/Jaccard_index). The resulting matrix can be further analyzed (e.g., with `R`) using unsupervised learning techniques such as cluster characterization, dimensionality reduction, or graph-based analytics.
1+
# Cohort Mode
2+
3+
_Cohort mode_ performs an all-vs-all comparison of records in one or more cohorts. Each record is flattened, encoded as a binary vector, and compared with either [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) or the [Jaccard index](https://en.wikipedia.org/wiki/Jaccard_index).
4+
5+
Use cohort mode when you want to explore the structure of a cohort, compare multiple cohorts, identify clusters, run dimensionality reduction, or export a graph for network analysis.
6+
7+
## What You Get
8+
9+
- `matrix.txt`: the default dense pairwise comparison matrix.
10+
- `graph.json`: an optional Cytoscape-compatible graph when `--cytoscape-json` is used.
11+
- `graph_stats.txt`: optional graph summary statistics when `--graph-stats` is used.
12+
- `export.*.json`: optional intermediate hashes, vectors, and coverage statistics when `--export` is used.
13+
- `matrix.mtx`: optional sparse Matrix Market output for large matrix workflows.
14+
15+
[See common usage](usage.md){ .md-button .md-button--primary }
16+
[Read generic JSON tutorial](generic-json.md){ .md-button }
17+
[Check installation](download-and-installation.md){ .md-button }
218

319
???+ Example "Generic JSON tutorial"
420
We created a [tutorial](generic-json.md) that deliberately uses generic JSON data (i.e., movies) to illustrate the capabilities of `Pheno-Ranker`, as starting with familiar examples can help you better grasp its usage.
@@ -11,17 +27,18 @@ The examples below show common cohort-mode command-line patterns. For the comple
1127

1228
=== "Intra-cohort"
1329

14-
For this example, we'll use [`individuals.json`](https://github.com/CNAG-Biomedical-Informatics/pheno-ranker/blob/main/t/data/individuals.json), which contains a `JSON` array of 36 patients. We will conduct a comprehensive cross-comparison among all individuals within this file.
30+
For this example, we use [`individuals.json`](https://github.com/CNAG-Biomedical-Informatics/pheno-ranker/blob/main/t/data/individuals.json), a `JSON` array with 36 patients. The goal is to compare every patient against every other patient in the file.
1531

1632
First, we will download the file:
33+
1734
```bash
1835
wget https://raw.githubusercontent.com/CNAG-Biomedical-Informatics/pheno-ranker/refs/heads/main/t/data/individuals.json
1936
```
20-
And now we run `Pheno-Ranker`:
37+
38+
Now run `Pheno-Ranker`:
2139

2240
```bash
23-
pheno-ranker -r individuals.json
24-
41+
pheno-ranker -r individuals.json
2542
```
2643

2744
??? Example "More input examples"
@@ -33,6 +50,13 @@ The examples below show common cohort-mode command-line patterns. For the comple
3350
??? Example "See `matrix.txt`"
3451
--8<-- "tbl/matrix.md"
3552

53+
??? Tip "Defining the similarity metric"
54+
Use `--similarity-metric-cohort` to choose the cohort metric. The default value is `hamming`; the alternative is `jaccard`.
55+
56+
```bash
57+
pheno-ranker -r individuals.json --similarity-metric-cohort jaccard
58+
```
59+
3660
??? Tip "Sparse Matrix Market output"
3761
By default, cohort mode writes a dense tab-separated matrix (`matrix.txt`). For large cohorts, you can instead write a sparse [Matrix Market](https://math.nist.gov/MatrixMarket/formats.html) coordinate file:
3862

@@ -51,16 +75,13 @@ The examples below show common cohort-mode command-line patterns. For the comple
5175

5276
Matrix output and Cytoscape graph output are generated independently. This means `--matrix-format mtx` can be combined with `--cytoscape-json`.
5377

54-
??? Tip "Defining the similarity metric"
55-
Use the flag `--similarity-metric-cohort`. The default value is `hamming`. The alternative value is `jaccard`.
56-
5778
??? Tip "Exporting intermediate files"
58-
It is possible to export all intermediate files, as well as a file indicating coverage with the flag `--e`.
79+
It is possible to export all intermediate files, as well as a file indicating coverage, with `--export` (`--e`).
5980
Examples:
6081

6182
```bash
62-
pheno-ranker -r individuals.json --e
63-
pheno-ranker -r individuals.json --e my_fav_id # for choosing a prefix
83+
pheno-ranker -r individuals.json --export
84+
pheno-ranker -r individuals.json --export my_fav_id # choose a prefix
6485
```
6586

6687
The intermediate files can be used for further processing (e.g., import to a database; see [FAQs](faq.md)) or to make **informed decisions**. For instance, the file `export.coverage_stats.json` has stats on the coverage of each term (1D-key) in the cohort. It is possible to go more granular with a tool like `jq` that parses `JSON`. For instance:
@@ -158,11 +179,10 @@ The examples below show common cohort-mode command-line patterns. For the comple
158179

159180
=== "Inter-cohort"
160181

161-
We'll be using `individuals.json` again, which includes data for 36 patients. This time, however, we'll use it twice to simulate having two cohorts. The software will add a `CX_` prefix to the `primary_key` values to help us keep track of which patient comes from which usage of the file.
182+
We use `individuals.json` again, but pass it twice to simulate two cohorts. `Pheno-Ranker` adds a `CX_` prefix to the `primary_key` values so each record can be traced back to its source cohort.
162183

163184
```bash
164185
pheno-ranker -r individuals.json individuals.json
165-
166186
```
167187

168188
!!! Question "Is it possible to have a cohort with just one individual?"
@@ -178,8 +198,8 @@ The examples below show common cohort-mode command-line patterns. For the comple
178198

179199
```bash
180200
pheno-ranker -r individuals.json individuals.json --append-prefixes REF TAR
181-
182201
```
202+
183203
This will create a `matrix.txt` file of (36+36) x (36+36) cells. Again, this matrix can be processed with R:
184204

185205
<figure markdown>

docs/other-formats.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
`Pheno-Ranker` _a priori_ accepts as input "any" `JSON` or `YAML` array file. In order to do it, you'll need a **configuration file**. See a tutorial on how to use it [here](generic-json.md#moviepackets).
77

88
!!! Bug "What do you mean by "any" `JSON` or `YAML`?"
9-
`Pheno-Ranker` is capable of processing deeply nested data structures but has its limitations. If your data includes arrays nested more than one level deep, we recommend you that you tranform the 2D (or more) nested array elements into 1D objects.
9+
`Pheno-Ranker` is capable of processing deeply nested data structures but has its limitations. If your data includes arrays nested more than one level deep, we recommend transforming the 2D (or more) nested array elements into 1D objects.
1010

1111
=== "CSV"
1212

0 commit comments

Comments
 (0)