Skip to content

Commit

Permalink
Merge pull request #147 from rcannood/patch-1
Browse files Browse the repository at this point in the history
Fix `tfidf` to always use correct counts when from_layer is specified
  • Loading branch information
gtca authored Oct 17, 2024
2 parents ff3c0e1 + 782d85c commit d52b60d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions muon/_atac/preproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ def tfidf(
tf = np.dot(n_peaks, counts)
else:
n_peaks = np.asarray(counts.sum(axis=1)).reshape(-1, 1)
tf = adata.X / n_peaks
tf = counts / n_peaks

if scale_factor is not None and scale_factor != 0 and scale_factor != 1:
tf = tf * scale_factor
if log_tf:
tf = np.log1p(tf)

idf = np.asarray(adata.shape[0] / adata.X.sum(axis=0)).reshape(-1)
idf = np.asarray(adata.shape[0] / counts.sum(axis=0)).reshape(-1)
if log_idf:
idf = np.log1p(idf)

Expand Down

0 comments on commit d52b60d

Please sign in to comment.