Skip to main content

Module io

Module io 

Source
Expand description

Input/output for expression matrices, design and contrast matrices, and result tables. The delimited-text reader (read_matrix) lives behind the cli feature – it is the only consumer of the csv crate; everything else here (the design/contrast aligners and every table writer, including write_fit) is std-only and always compiled.

Structs§

LabeledMatrix
A labelled numeric matrix: data is rows x cols, with row_names and col_names taken from the first column and header row respectively.
WriteFitOptions
Options for write_fit, mirroring the arguments of limma’s write.fit.

Functions§

align_contrasts
Reorder the rows of a contrast matrix to match coef_order (the design’s coefficient names). Returns the n_coef x n_contrasts matrix.
align_design
Reorder the rows of design so they line up with sample_order (the expression-matrix column names), matching on row name. Returns the aligned n_samples x n_coef design matrix.
read_matrix
Read a labelled matrix from a delimited text file, choosing the delimiter from the file extension: .tsv / .tab are read tab-separated, everything else (.csv, .txt, no extension) comma-separated. The first row is a header whose first cell is an ignored corner label; the first column of each subsequent row is the row name. Empty / NA / NaN cells parse to f64::NAN. Use read_matrix_with_delimiter to force a delimiter.
read_matrix_with_delimiter
Read a labelled matrix from a delimited text file using an explicit delimiter byte (e.g. b',' or b'\t'). The first row is a header whose first cell is an ignored corner label; the first column of each subsequent row is the row name. Empty / NA / NaN cells parse to f64::NAN.
write_fit
Write an eBayes-processed MArrayLM fit to a delimited file, port of limma’s write.fit. The fit must already carry moderated t and p-values (run [crate::ebayes] or [crate::treat] first). Columns are emitted in limma’s order — AveExpr, then per-coefficient Coef, t, P.value, optional P.value.adj, then F/F.p.value (when present) and optional F.p.value.adj, then optional Results from a decideTests matrix. With a single coefficient the per-coefficient columns carry no .<name> suffix, matching R’s drop().
write_fit_dump
Dump the full per-gene fit statistics in original gene order, one CSV row per gene per coefficient. Used for numerical parity checks against R limma.
write_test_results
Write a decideTests outcome matrix (genes x contrasts) of -1/0/1, in original gene order. Header is id followed by the contrast names.
write_top_table
Write a single-contrast top table.
write_top_table_f
Write a multi-contrast (F-statistic) top table.