Skip to content

Commit

Permalink
fix #221
Browse files Browse the repository at this point in the history
  • Loading branch information
kaizhang committed Jan 29, 2024
1 parent 143c92d commit b2415c9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release Notes

## Development version (unreleased)

### Bugs fixed:

- Fix: #221: 'pp.knn' with 'method=pynndescent' invalid csr matrix.

## Release 2.5.3 (released Jan 16, 2024)

### Features:
Expand Down
1 change: 0 additions & 1 deletion snapatac2-python/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions snapatac2-python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ homepage = "https://github.com/"
keywords = ["single-cell", "biology"]

[dependencies]
#snapatac2-core = { path = "../snapatac2-core" }
snapatac2-core = { git = "https://github.com/kaizhang/SnapATAC2.git", rev = "ab502b5ed67492d3428fb01b3f4ab7cee6b32566" }
snapatac2-core = { path = "../snapatac2-core" }
#snapatac2-core = { git = "https://github.com/kaizhang/SnapATAC2.git", rev = "ab502b5ed67492d3428fb01b3f4ab7cee6b32566" }
anndata = "0.2"
anndata-hdf5 = "0.1"
pyanndata = "0.2"
Expand Down
11 changes: 8 additions & 3 deletions snapatac2-python/snapatac2/preprocessing/_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def make_fragment_file(
Note
----
When using `barcode_regex` or `umi_regex`, the regex must contain exactly one capturing group
(Parentheses group the regex between them) that matches the barcodes or UMIs.
Writting the correct regex is tricky. You can test your regex online at https://regex101.com/.
BAM files produced by the 10X Genomics Cell Ranger pipeline are not supported,
as they contain invalid BAM headers. Specifically, Cell Ranger ATAC <= 2.0 produces BAM
files with no @VN tag in the header, and Cell Ranger ATAC >= 2.1 produces BAM files
Expand All @@ -66,7 +69,7 @@ def make_fragment_file(
Extract barcodes from read names of BAM records using regular expressions.
Reguler expressions should contain exactly one capturing group
(Parentheses group the regex between them) that matches
the barcodes. For example, `barcode_regex="(..:..:..:..):\w+$"`
the barcodes. For example, `barcode_regex="(..:..:..:..):\\w+$"`
extracts `bd:69:Y6:10` from
`A01535:24:HW2MMDSX2:2:1359:8513:3458:bd:69:Y6:10:TGATAGGTTG`.
umi_tag
Expand Down Expand Up @@ -732,7 +735,6 @@ def _find_most_accessible_features(
idx = idx[n_lower:n-n_upper]
return idx[::-1][:total_features]


def select_features(
adata: internal.AnnData | internal.AnnDataSet | list[internal.AnnData],
n_features: int = 500000,
Expand All @@ -746,12 +748,15 @@ def select_features(
verbose: bool = True,
) -> np.ndarray | list[np.ndarray] | None:
"""
Perform feature selection.
Perform feature selection by selecting the most accessibile features across
all cells unless `max_iter` > 1.
Note
----
This function does not perform the actual subsetting. The feature mask is used by
various functions to generate submatrices on the fly.
Features that are zero in all cells will be always removed regardless of the
filtering criteria.
For more discussion about feature selection, see: https://github.com/kaizhang/SnapATAC2/discussions/116.
Parameters
Expand Down
1 change: 1 addition & 0 deletions snapatac2-python/snapatac2/preprocessing/_knn.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def knn(
distances = np.ravel(distances[:, :n_neighbors])
indptr = np.arange(0, distances.size + 1, n_neighbors)
adj = csr_matrix((distances, indices, indptr), shape=(n, n))
adj.sort_indices()
elif method == 'kdtree':
adj = internal.nearest_neighbour_graph(data, n_neighbors)
else:
Expand Down

0 comments on commit b2415c9

Please sign in to comment.