Skip to content

Commit

Permalink
mkmd.sh doc-gen
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Jun 21, 2022
1 parent c3eae12 commit 8e9fe52
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 25 deletions.
44 changes: 23 additions & 21 deletions apis/python/doc/annotation_dataframe.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,46 +55,59 @@ def keys() -> List[str]
Returns the column names for the `obs` or `var` dataframe. For obs and varp, `.keys()` is a
keystroke-saver for the more general array-schema accessor `attr_names`.

<a id="tiledbsc.annotation_dataframe.AnnotationDataFrame.keyset"></a>

#### keyset

```python
def keyset() -> Set[str]
```

Same as `.keys` but returns as set.

<a id="tiledbsc.annotation_dataframe.AnnotationDataFrame.dim_select"></a>

#### dim\_select

```python
def dim_select(ids)
def dim_select(ids, attrs=None)
```

Selects a slice out of the dataframe with specified `obs_ids` (for `obs`) or `var_ids` (for `var`).
If `ids` is `None`, the entire dataframe is returned.
Selects a slice out of the dataframe with specified `obs_ids` (for `obs`) or `var_ids` (for
`var`). If `ids` is `None`, the entire dataframe is returned. Similarly, if `attrs` are
provided, they're used for the query; else, all attributes are returned.

<a id="tiledbsc.annotation_dataframe.AnnotationDataFrame.df"></a>

#### df

```python
def df(ids=None) -> pd.DataFrame
def df(ids=None, attrs=None) -> pd.DataFrame
```

Keystroke-saving alias for `.dim_select()`. If `ids` are provided, they're used
to subselect; if not, the entire dataframe is returned.
to subselect; if not, the entire dataframe is returned. If `attrs` are provided,
they're used for the query; else, all attributes are returned.

<a id="tiledbsc.annotation_dataframe.AnnotationDataFrame.attribute_filter"></a>

#### attribute\_filter

```python
def attribute_filter(query_string, col_names_to_keep)
def attribute_filter(query_string, attrs=None)
```

Selects from obs/var using a TileDB-Py `QueryCondition` string such as
`cell_type == "blood"`. Returns None if the slice is empty.
This is a v1 implementation for the prototype/demo timeframe.
Selects from obs/var using a TileDB-Py `QueryCondition` string such as `cell_type ==
"blood"`. If `attrs` is `None`, returns all column names in the dataframe; use `[]` for
`attrs` to select none of them. Any column names specified in the `query_string` must be
included in `attrs` if `attrs` is not `None`. Returns `None` if the slice is empty.

<a id="tiledbsc.annotation_dataframe.AnnotationDataFrame.from_dataframe"></a>

#### from\_dataframe

```python
def from_dataframe(dataframe: pd.DataFrame, extent: int) -> None
def from_dataframe(dataframe: pd.DataFrame, extent: int = 2048) -> None
```

Populates the `obs` or `var` subgroup for a SOMA object.
Expand All @@ -104,14 +117,3 @@ Populates the `obs` or `var` subgroup for a SOMA object.
- `dataframe`: `anndata.obs`, `anndata.var`, `anndata.raw.var`.
- `extent`: TileDB `extent` parameter for the array schema.

<a id="tiledbsc.annotation_dataframe.AnnotationDataFrame.to_dataframe"></a>

#### to\_dataframe

```python
def to_dataframe() -> pd.DataFrame
```

Reads the TileDB `obs` or `var` array and returns a type of pandas dataframe
and dimension values.

26 changes: 25 additions & 1 deletion apis/python/doc/assay_matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Note: currently implemented via data scan -- will be optimized for TileDB core 2
#### dim\_select

```python
def dim_select(obs_ids, var_ids)
def dim_select(obs_ids, var_ids) -> pd.DataFrame
```

Selects a slice out of the matrix with specified `obs_ids` and/or `var_ids`.
Expand All @@ -80,6 +80,26 @@ def df(obs_ids=None, var_ids=None) -> pd.DataFrame
Keystroke-saving alias for `.dim_select()`. If either of `obs_ids` or `var_ids`
are provided, they're used to subselect; if not, the entire dataframe is returned.

<a id="tiledbsc.assay_matrix.AssayMatrix.csr"></a>

#### csr

```python
def csr(obs_ids=None, var_ids=None) -> scipy.sparse.csr_matrix
```

Like `.df()` but returns results in `scipy.sparse.csr_matrix` format.

<a id="tiledbsc.assay_matrix.AssayMatrix.csc"></a>

#### csc

```python
def csc(obs_ids=None, var_ids=None) -> scipy.sparse.csc_matrix
```

Like `.df()` but returns results in `scipy.sparse.csc_matrix` format.

<a id="tiledbsc.assay_matrix.AssayMatrix.from_matrix_and_dim_values"></a>

#### from\_matrix\_and\_dim\_values
Expand All @@ -91,6 +111,10 @@ def from_matrix_and_dim_values(matrix, row_names, col_names) -> None
Imports a matrix -- nominally `scipy.sparse.csr_matrix` or `numpy.ndarray` -- into a TileDB
array which is used for `X`, `raw.X`, `obsp` members, and `varp` members.

The `row_names` and `col_names` are row and column labels for the matrix; the matrix may be
`scipy.sparse.csr_matrix`, `scipy.sparse.csc_matrix`, `numpy.ndarray`, etc.
For ingest from `AnnData`, these should be `ann.obs_names` and `ann.var_names`.

<a id="tiledbsc.assay_matrix.AssayMatrix.ingest_data_whole"></a>

#### ingest\_data\_whole
Expand Down
9 changes: 6 additions & 3 deletions apis/python/doc/assay_matrix_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,15 @@ def __contains__(name)

Implements the `in` operator, e.g. `"data" in soma.X`.
<a id="tiledbsc.assay_matrix_group.AssayMatrixGroup.from_matrix_and_dim_values"></a>
<a id="tiledbsc.assay_matrix_group.AssayMatrixGroup.add_layer_from_matrix_and_dim_values"></a>

#### from\_matrix\_and\_dim\_values
#### add\_layer\_from\_matrix\_and\_dim\_values

```python
def from_matrix_and_dim_values(matrix, row_names, col_names) -> None
def add_layer_from_matrix_and_dim_values(matrix,
row_names: str,
col_names: str,
layer_name="data") -> None
```

Populates the `X` or `raw.X` subgroup for a `SOMA` object. For `X` and `raw.X`, nominally `row_names` will be `anndata.obs_names` and `col_names` will be `anndata.var_names` or `anndata.raw.var_names`. For `obsp` elements, both will be `anndata.obs_names`; for `varp elements, both will be `anndata.var_names`.
Expand Down
32 changes: 32 additions & 0 deletions apis/python/doc/soma.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,35 @@ def var_keys()

An alias for `soma.var.ids()`.

<a id="tiledbsc.soma.SOMA.cell_count"></a>

#### cell\_count

```python
def cell_count() -> int
```

Returns the `obs_id` in `soma.obs`.

<a id="tiledbsc.soma.SOMA.get_obs_value_counts"></a>

#### get\_obs\_value\_counts

```python
def get_obs_value_counts(obs_label: str) -> pd.DataFrame
```

Given an obs label, e.g. `cell_type`, returns a dataframe count the number of different
values for that label in the SOMA.

<a id="tiledbsc.soma.SOMA.get_var_value_counts"></a>

#### get\_var\_value\_counts

```python
def get_var_value_counts(var_label: str) -> pd.DataFrame
```

Given an var label, e.g. `feature_name`, returns a dataframe count the number of different
values for that label in the SOMA.

76 changes: 76 additions & 0 deletions apis/python/doc/soma_collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ Create a new `SOMACollection` object. The existing group is opened at the specif
- `uri`: URI of the TileDB group
- `verbose`: Print status messages

<a id="tiledbsc.soma_collection.SOMACollection.__len__"></a>

#### \_\_len\_\_

```python
def __len__() -> int
```

Implements `len(soco)`. Returns the number of elements in the collection.

<a id="tiledbsc.soma_collection.SOMACollection.add"></a>

#### add
Expand All @@ -53,6 +63,16 @@ def remove(soma: SOMA) -> None

Removes a `SOMA` from the `SOMACollection`.

<a id="tiledbsc.soma_collection.SOMACollection.keys"></a>

#### keys

```python
def keys() -> None
```

Returns the names of the SOMAs in the collection.

<a id="tiledbsc.soma_collection.SOMACollection.__iter__"></a>

#### \_\_iter\_\_
Expand Down Expand Up @@ -84,3 +104,59 @@ def __getitem__(name)
Returns a `SOMA` element at the given name within the group, or `None` if no such
member exists. Overloads the `[...]` operator.

<a id="tiledbsc.soma_collection.SOMACollection.cell_count"></a>

#### cell\_count

```python
def cell_count() -> int
```

Returns sum of `soma.cell_count()` over SOMAs in the collection.

<a id="tiledbsc.soma_collection.SOMACollection.find_unique_obs_values"></a>

#### find\_unique\_obs\_values

```python
def find_unique_obs_values(obs_label: str)
```

Given an `obs` label such as `cell_type` or `tissue`, returns a list of unique values for
that label among all SOMAs in the collection.

<a id="tiledbsc.soma_collection.SOMACollection.find_unique_var_values"></a>

#### find\_unique\_var\_values

```python
def find_unique_var_values(var_label: str)
```

Given an `var` label such as `feature_name`, returns a list of unique values for
that label among all SOMAs in the collection.

<a id="tiledbsc.soma_collection.SOMACollection.get_obs_value_counts"></a>

#### get\_obs\_value\_counts

```python
def get_obs_value_counts(obs_label: str, do_sum: bool)
```

For a given obs label, e.g. "cell_type", count the number of occurrences of different values in
SOMAs in the collection. If `do_sum` is false, count the number of SOMAs having that value. If
`do_sum` is true, count the total number of instances of that value across the collection.

<a id="tiledbsc.soma_collection.SOMACollection.get_var_value_counts"></a>

#### get\_var\_value\_counts

```python
def get_var_value_counts(var_label: str, do_sum: bool)
```

For a given var label, e.g. "feature_name", count the number of occurrences of different values in
SOMAs in the collection. If `do_sum` is false, count the number of SOMAs having that value. If
`do_sum` is true, count the total number of instances of that value across the collection.

10 changes: 10 additions & 0 deletions apis/python/doc/tiledb_array.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ def has_attr_name(attr_name: str) -> bool

Returns true if the array has the specified attribute name, false otherwise.

<a id="tiledbsc.tiledb_array.TileDBArray.has_attr_names"></a>

#### has\_attr\_names

```python
def has_attr_names(attr_names: List[str]) -> bool
```

Returns true if the array has all of the specified attribute names, false otherwise.

<a id="tiledbsc.tiledb_array.TileDBArray.show_metadata"></a>

#### show\_metadata
Expand Down
33 changes: 33 additions & 0 deletions apis/python/doc/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

# tiledbsc.util

<a id="tiledbsc.util.is_local_path"></a>

#### is\_local\_path

```python
def is_local_path(path: str) -> bool
```

Returns information about start time of an event. Nominally float seconds since the epoch,
but articulated here as being compatible with the format_elapsed function.

<a id="tiledbsc.util.get_start_stamp"></a>

#### get\_start\_stamp
Expand All @@ -24,6 +35,28 @@ def format_elapsed(start_stamp, message: str)
Returns the message along with an elapsed-time indicator, with end time relative to start
start from `get_start_stamp`. Used for annotating elapsed time of a task.

<a id="tiledbsc.util.X_and_ids_to_sparse_matrix"></a>

#### X\_and\_ids\_to\_sparse\_matrix

```python
def X_and_ids_to_sparse_matrix(
Xdf: pd.DataFrame,
row_dim_name: str,
col_dim_name: str,
attr_name: str,
row_labels: List[str],
col_labels: List[str],
return_as: str = "csr"
) -> Union[scipy.sparse.csr_matrix, scipy.sparse.csc_matrix]
```

This is needed when we read a TileDB X.df[:]. Since TileDB X is sparse 2D string-dimensioned,
the return value of which is a dict with three columns -- obs_id, var_id, and value. For
conversion to anndata, we need make a sparse COO/IJV-format array where the indices are
not strings but ints, matching the obs and var labels.
The `return_as` parameter must be one of `"csr"` or `"csc"`.

<a id="tiledbsc.util.ETATracker"></a>

## ETATracker Objects
Expand Down

0 comments on commit 8e9fe52

Please sign in to comment.