Skip to main content

How to use a CSV with Pheno-Ranker

RoleUtility-assisted input
Accepted inputDelimited text table
ConfigurationGenerated by csv2pheno-ranker
Best forTabular categorical data
CSV table converted into JSON records and a matching Pheno-Ranker configuration
csv2pheno-ranker creates the JSON records and configuration required by Pheno-Ranker.

The companion csv2pheno-ranker command converts a CSV or TSV table into two files: a JSON array of records and a matching Pheno-Ranker configuration.

Categorical data

Pheno-Ranker compares categorical values. Convert continuous measurements into meaningful categories or ranges before using them in a comparison. The choice of ranges should be justified by the domain rather than selected only for the software.

Convert a table

Suppose example.csv uses semicolons between columns and commas between values inside the Bar column:

FooBarBaz
foo1bar1a,bar1bbaz1
foo2bar2a,bar2bbaz2

The table has no unique row identifier. Convert it with:

csv2pheno-ranker -i example.csv --separator ';' --array-separator ',' --generate-primary-key --primary-key-name Id
OptionMeaning in this example
--separator ';'Columns are separated by semicolons.
--array-separator ','Values inside Bar are separated by commas.
--generate-primary-keyCreate a unique identifier for every row.
--primary-key-name IdName the generated identifier field Id.

If the table already has a unique, single-value identifier column, omit --generate-primary-key and pass that column name with --primary-key-name.

Check the generated files

The command creates example.json:

[
{
"Bar": ["bar1a", "bar1b"],
"Baz": "baz1",
"Foo": "foo1",
"Id": "PR_00000001"
},
{
"Bar": ["bar2a", "bar2b"],
"Baz": "baz2",
"Foo": "foo2",
"Id": "PR_00000002"
}
]

It also creates example_config.yaml:

---
allowed_terms:
- Bar
- Baz
- Foo
- Id
indexed_terms:
- Bar
format: CSV
identity_paths:
CSV:
- Bar: Bar
primary_key: Id

The configuration records which field identifies each row and which columns can be compared. It also records that Bar contains multiple values.

Run Pheno-Ranker

Pass both generated files to the main CLI:

pheno-ranker -r example.json --config example_config.yaml

The default cohort output is matrix.txt. To omit columns from the comparison:

pheno-ranker -r example.json --config example_config.yaml --exclude-terms Id Foo

Always use the generated configuration when working with the converted JSON.

CSV data checks
  • Use unique, non-empty column names.
  • Use one consistent value for each category; for example, do not mix M and Male unless they intentionally represent different categories.
  • .csv files use commas and .tsv files use tabs by default. Override that behavior with --separator when necessary.
  • Use --array-separator only for columns containing multiple categorical values. Its default is |.
  • When comparing tables from different cohorts, confirm that corresponding columns and category names use the same nomenclature.