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
xis not a supported type.- Returns:
List of column names.
- Return type:
- 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, orcombine_rows()for n-dimensional objects.- Parameters:
x (Any) –
Objects to combine.
All elements of
xare 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’sconcatenate().If all elements are either
spmatrixorsparray, these objects are combined using scipy’shstack.If all elements are
DataFrameobjects, they are combined usingconcat()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. Andarray, 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’sconcatenate().If all elements are either
spmatrixorsparray, these objects are combined using scipy’svstack.If all elements are
DataFrameobjects, they are combined usingconcat()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. Andarray, 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’sconcatenate().If all elements are either
spmatrixorsparray, these objects are combined using scipy’shstack.If all elements are
Seriesobjects, they are combined usingconcat().For all other scenario’s, all elements are coerced to a
listand combined.- Parameters:
x (Any) –
Vector-like objects to combine.
All elements of
xare 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. Andarray, if the elements are a mix of dense and sparse objects. Alist, if one of the objects is alist.
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
xis 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
xis 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:
- biocgenerics.show_as_cell.show_as_cell(x: Any, indices: Sequence[int]) List[str][source]#
Show the contents of
xas a cell of a table, typically for use in the__str__method of a class that containsx.- 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 ofx.