biocgenerics package#

Submodules#

biocgenerics.colnames module#

biocgenerics.colnames.colnames(x) list[source]#
biocgenerics.colnames.colnames(x: DataFrame) list

Access column names from 2-dimensional representations.

Parameters:

x – Any object.

Raises:

NotImplementedError – If x is not a supported type.

Returns:

List of column names.

Return type:

list

biocgenerics.colnames.set_colnames(x, names: List[str])[source]#
biocgenerics.colnames.set_colnames(x: DataFrame, names: List[str])

Set column names.

Parameters:
  • x – Any object.

  • names (List[str]) – New names.

Raises:

NotImplementedError – if type is not supported.

Returns:

An object with the same type as x.

biocgenerics.combine module#

biocgenerics.combine.combine(*x: Any)[source]#
biocgenerics.combine.combine(*x: list)
biocgenerics.combine.combine(*x: ndarray)
biocgenerics.combine.combine(*x: sparray)
biocgenerics.combine.combine(*x: spmatrix)
biocgenerics.combine.combine(*x: Series)
biocgenerics.combine.combine(*x: DataFrame)

Generic combine that delegates calls to combine_seqs() for 1-dimensional or vector like objects, or combine_rows() for n-dimensional objects.

Parameters:

x (Any) –

Objects to combine.

All elements of x are expected to be the same class or atleast compatible with each other.

Returns:

A combined object, typically the same type as the first element in x.

biocgenerics.combine_cols module#

biocgenerics.combine_cols.combine_cols(*x: Any)[source]#
biocgenerics.combine_cols.combine_cols(*x: ndarray)
biocgenerics.combine_cols.combine_cols(*x: sparray)
biocgenerics.combine_cols.combine_cols(*x: spmatrix)
biocgenerics.combine_cols.combine_cols(*x: DataFrame)

Combine n-dimensional objects along the second dimension.

If all elements are ndarray, we combine them using numpy’s concatenate().

If all elements are either spmatrix or sparray, these objects are combined using scipy’s hstack.

If all elements are DataFrame objects, they are combined using concat() along the second axis.

Parameters:

x (Any) –

n-dimensional objects to combine.

All elements of x are expected to be the same class or atleast compatible with each other.

Returns:

A combined object, typically the same type as the first element in x. A ndarray, if the elements are a mix of dense and sparse objects.

biocgenerics.combine_rows module#

biocgenerics.combine_rows.combine_rows(*x: Any)[source]#
biocgenerics.combine_rows.combine_rows(*x: ndarray)
biocgenerics.combine_rows.combine_rows(*x: sparray)
biocgenerics.combine_rows.combine_rows(*x: spmatrix)
biocgenerics.combine_rows.combine_rows(*x: DataFrame)

Combine n-dimensional objects along their first dimension.

If all elements are ndarray, we combine them using numpy’s concatenate().

If all elements are either spmatrix or sparray, these objects are combined using scipy’s vstack.

If all elements are DataFrame objects, they are combined using concat() along the first axis.

Parameters:

x (Any) –

n-dimensional objects to combine.

All elements of x are expected to be the same class or atleast compatible with each other.

Returns:

A combined object, typically the same type as the first element in x. A ndarray, if the elements are a mix of dense and sparse objects.

biocgenerics.combine_seqs module#

biocgenerics.combine_seqs.combine_seqs(*x: Any)[source]#
biocgenerics.combine_seqs.combine_seqs(*x: list)
biocgenerics.combine_seqs.combine_seqs(*x: ndarray)
biocgenerics.combine_seqs.combine_seqs(*x: sparray)
biocgenerics.combine_seqs.combine_seqs(*x: spmatrix)
biocgenerics.combine_seqs.combine_seqs(*x: Series)

Combine vector-like objects (1-dimensional arrays).

If all elements are ndarray, we combine them using numpy’s concatenate().

If all elements are either spmatrix or sparray, these objects are combined using scipy’s hstack.

If all elements are Series objects, they are combined using concat().

For all other scenario’s, all elements are coerced to a list and combined.

Parameters:

x (Any) –

Vector-like objects to combine.

All elements of x are expected to be the same class or atleast compatible with each other.

Raises:

TypeError – If any object in the list cannot be coerced to a list.

Returns:

A combined object, typically the same type as the first element in x. A ndarray, if the elements are a mix of dense and sparse objects. A list, if one of the objects is a list.

biocgenerics.rownames module#

biocgenerics.rownames.rownames(x) List[str][source]#
biocgenerics.rownames.rownames(x: DataFrame) list

Access row names from 2-dimensional representations.

Parameters:

x – Any object.

Raises:

NotImplementedError – If x is not a supported type.

Returns:

List of row names.

Return type:

List[str]

biocgenerics.rownames.set_rownames(x: Any, names: List[str])[source]#
biocgenerics.rownames.set_rownames(x: DataFrame, names: List[str])

Set row names.

Parameters:
  • x (Any) – supported object.

  • names (List[str]) – New names.

Raises:

NotImplementedError – If x is not a supported type.

Returns:

An object with the same type as x.

biocgenerics.show_as_cell module#

biocgenerics.show_as_cell.format_table(columns: List[Sequence[str]], floating_names: Sequence[str] | None = None, sep: str = ' ', window: int | None = None) str[source]#

Pretty-print a table with wrapping columns.

Parameters:
  • columns – List of list of strings, where each inner list is the same length. Strings are typically generated by show_as_cell().

  • floating_names – List of strings to be added to the left of the table. This is printed repeatedly for each set of wrapped columns.

  • sep – Separator between columns.

  • window – Size of the terminal window, in characters. We attempt to determine this automatically, otherwise it is set to 150.

Returns:

String containing the pretty-printed table.

Return type:

str

biocgenerics.show_as_cell.show_as_cell(x: Any, indices: Sequence[int]) List[str][source]#

Show the contents of x as a cell of a table, typically for use in the __str__ method of a class that contains x.

Parameters:
  • x – Any object. By default, we assume that it can be treated as a sequence, with a valid __getitem__ method for an index.

  • indices – List of indices to be extracted.

Returns:

List of strings of length equal to indices, containing a string summary of each of the specified elements of x.

biocgenerics.utils module#

Module contents#