ecotyper.rcompat.io

Readers/writers for the tab-delimited files EcoTyper’s R scripts exchange.

  • read_delim() mimics read.delim (header, check.names, automatic row names when the header has one field less, type.convert).

  • write_table() mimics write.table(x, sep = "\t") including R’s number formatting (15 significant digits, fixed vs. scientific choice), so files written by the port can be diffed byte for byte with R’s.

Functions

format_real(x[, digits])

Format one double as write.table does (formatReal + EncodeReal0 with digits = 15).

format_rows(mat[, digits])

Rows of a float matrix formatted as format_real() (NaN as NA), cells joined by tabs.

read_delim(path[, check_names, ...])

read.delim(path).

read_expression(path[, check_names, ...])

Read an expression matrix with gene names in the first column (fread(path, data.table = F); check_names=True emulates read.delim).

read_matrix(path[, check_names])

Read a numeric matrix written by write.table (row names + header).

write_matrix(mat, rows, cols, path)

write.table(matrix_with_dimnames, sep = "\t").

write_table(df, path[, row_names, ...])

write.table(df, path, sep = "\t", row.names = row_names).

ecotyper.rcompat.io.read_delim(path, check_names=True, row_names_col=None, numeric_only=False)[source]

read.delim(path).

Row names (if the header has one field less than the data, or row_names_col=True) become the index as strings; otherwise the index is "1".."n" like R’s automatic row names.

Parameters:
  • check_names (bool)

  • row_names_col (bool | None)

  • numeric_only (bool)

Return type:

DataFrame

ecotyper.rcompat.io.read_matrix(path, check_names=True)[source]

Read a numeric matrix written by write.table (row names + header).

Parameters:

check_names (bool)

Return type:

DataFrame

ecotyper.rcompat.io.read_expression(path, check_names=False, dedup_first_col=True)[source]

Read an expression matrix with gene names in the first column (fread(path, data.table = F); check_names=True emulates read.delim).

Parameters:
  • check_names (bool)

  • dedup_first_col (bool)

Return type:

DataFrame

ecotyper.rcompat.io.format_real(x, digits=15)[source]

Format one double as write.table does (formatReal + EncodeReal0 with digits = 15).

Parameters:
Return type:

str

ecotyper.rcompat.io.format_rows(mat, digits=15)[source]

Rows of a float matrix formatted as format_real() (NaN as NA), cells joined by tabs.

Parameters:
Return type:

list[str]

ecotyper.rcompat.io.write_table(df, path, row_names=True, col_names=True, quote_numeric_index=True)[source]

write.table(df, path, sep = "\t", row.names = row_names).

Parameters:
Return type:

None

ecotyper.rcompat.io.write_matrix(mat, rows, cols, path)[source]

write.table(matrix_with_dimnames, sep = "\t").

Parameters:

mat (ndarray)

Return type:

None