Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# Changelog

## Version 0.6.0 - 0.6.3
## Version 0.6.0 - 0.6.4

- Changed related to SummarizedExperiment and implementation of `CompressedGenomicRangesList` in the genomic ranges package.
- Update versions of relevant dependency packages.
- Rename `reduced_dims` to `reduced_dimensions`.
- Implement coercions to/from RSE/SE.
- Access data stored in `raw` (if available) as `alternative_experiments`, when initializing `SingleCellExperiment` objects from anndata/h5ad files.
- Fix bug when slicing objects containing row or column pairs.
- Add getters/setters for `sizeFactors`, modifying this in the column_data of the object.
- Improve test coverage and fix bugs.

## Version 0.5.8 - 0.5.9

Expand Down
29 changes: 29 additions & 0 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,35 @@ One can access an reduced dimension by index or name:
sce.reduced_dim(0) # same as se.reduced_dim("random_embeds")
```

## Size Factors

In Bioconductor, size factors represent scaling factors used to normalize cell-specific biases (such as differences in sequencing depth). Following the Bioconductor design, `SingleCellExperiment` stores size factors directly inside the column data under the column name `"sizeFactors"`.

You can set, retrieve, and delete size factors using either functional methods or the `size_factors` property:

```{code-cell}
# Generate mock size factors (e.g. library size scaling factors)
cell_depths = counts.sum(axis=0)
if isinstance(cell_depths, np.matrix) or hasattr(cell_depths, "A"):
cell_depths = np.array(cell_depths).flatten()

# Scale factors so that their mean is 1
size_factors = cell_depths / np.mean(cell_depths)

# Set size factors on the experiment
sce.set_size_factors(size_factors, in_place=True)

# Access size factors
print("Retrieved size factors:", sce.get_size_factors())

# They reside directly in the column_data under "sizeFactors":
print("Column data 'sizeFactors':", sce.column_data["sizeFactors"])

# To delete/remove size factors, set them to None
sce.set_size_factors(None, in_place=True)
print("After deletion, is 'sizeFactors' in column_data?", "sizeFactors" in sce.column_data.column_names)
```

## Subset experiments

You can subset experimental data by using the subset (`[]`) operator. This operation accepts different slice input types, such as a boolean vector, a `slice` object, a list of indices, or names (if available) to subset.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ version_scheme = "no-guess-dev"
[tool.ruff]
line-length = 120
src = ["src"]
exclude = ["tests"]
# exclude = ["tests"]
extend-ignore = ["F821"]

[tool.ruff.pydocstyle]
Expand Down
Loading
Loading