Expand description
§csvranger
csranger is a library for parsing the output CSV files of 10x Genomics *ranger pipelines.
Many of 10x Genomics data-processing pipelines produce CSV files that summarize the data. These CSVs, while human-readable, cannot be parsed by a machine without extra effort. This small crate provides the necessary functionality to parse the values in these files. See documentation at csvranger.
§Example usage
§Using TenxCsvValue::from_csv_value
use csvranger::TenxCsvValue;
fn main() {
// Sample data from test-data/cellranger_multi.10.0
let raw_csv = b"Sample ID,Sample barcodes,Sample description,GEX: Cells,GEX: Confidently mapped reads in cells,GEX: Median UMI counts per cell,GEX: Median genes per cell,GEX: Total genes detected
SOD1_G93A_mouse_spinal_cord_P112_specimen_1,,SOD1-G93A mouse spinal cord from P112 mouse,16410,0.6847850295990157,2244,1305,27219";
let mut reader = csv::Reader::from_reader(&raw_csv[..]);
for line in reader.records() {
// Don't actually call .unwrap in production!
let line = line.unwrap();
for value in line.iter() {
// This is where the magic happens
TenxCsvValue::from_csv_value(value);
}
}
}§Deserializing directly
use csvranger::TenxCsvValue;
use std::collections::HashMap;
fn main() {
// Sample data from test-data/cellranger_multi.10.0
let raw_csv = b"Sample ID,Sample barcodes,Sample description,GEX: Cells,GEX: Confidently mapped reads in cells,GEX: Median UMI counts per cell,GEX: Median genes per cell,GEX: Total genes detected
SOD1_G93A_mouse_spinal_cord_P112_specimen_1,,SOD1-G93A mouse spinal cord from P112 mouse,16410,0.6847850295990157,2244,1305,27219";
let mut reader = csv::Reader::from_reader(&raw_csv[..]);
let mut parsed_data: Vec<HashMap<String, TenxCsvValue>> = Vec::new();
#[cfg(feature = "serde")]
for deserialized_record in reader.deserialize() {
parsed_data.push(deserialized_record.unwrap())
}
}Enums§
- Tenx
CsvValue - A CSV value found in the
metrics_summary.csvfiles produced by 10x Genomics *ranger pipelines.
Functions§
- parse_
legacy_ csv_ value_ as_ f64 - Parse a value in a CSV outputted by a legacy 10x Genomics pipeline as an
f64. - parse_
legacy_ csv_ value_ as_ i64 - Parse a value in a CSV outputted by a legacy 10x Genomics pipeline as an
i64.