Skip to content

Commit

Permalink
Fixed an error in ov.utils.roe when some expected frequencies are l…
Browse files Browse the repository at this point in the history
…ess than expected value.
  • Loading branch information
Starlitnightly committed Jul 25, 2024
1 parent efa3e16 commit b520a0d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ If you use `omicverse` in your work, please cite the `omicverse` publication as
>
> Zeng, Z., Ma, Y., Hu, L. et al.
>
> _Nature Communication_ 2024 Jul 17. doi: [10.1038/s41467-024-50194-3](https://doi.org/10.1038/s41467-024-50194-3).
> _Nature Communication_ 2024 Jul 16. doi: [10.1038/s41467-024-50194-3](https://doi.org/10.1038/s41467-024-50194-3).

## `8` [Other](#)
Expand Down
16 changes: 11 additions & 5 deletions omicverse/externel/spatrio/spatrio.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def ot_alignment(
norm: str = 'l2',
backend = None,
return_obj: bool = False,
verbose: bool = False,
verbose: bool = True,
k: int = 10,
graph_mode: str = "connectivity",
aware_spatial: bool = True,
Expand Down Expand Up @@ -541,14 +541,20 @@ def f(G):
def df(G):
return ot.gromov.gwggrad(constC, hC1, hC2, G)
if log:
res, log = ot.gromov.cg(p, q, (1 - alpha) * M, alpha, f, df, G0, armijo=armijo, C1=C1, C2=C2, constC=constC, log=True, numItermaxEmd=numItermaxEmd, **kwargs)

if ot.__version__ < '0.9.0':
res, log = ot.gromov.cg(p, q, (1 - alpha) * M, alpha, f, df, G0, armijo=armijo, C1=C1, C2=C2, constC=constC, log=True, numItermaxEmd=numItermaxEmd, **kwargs)
else:
res, log = ot.optim.cg(p, q, (1 - alpha) * M, alpha, f, df, G0, armijo=armijo, C1=C1, C2=C2, constC=constC, log=True, numItermaxEmd=numItermaxEmd, **kwargs)

fgw_dist = log['loss'][-1]

log['fgw_dist'] = fgw_dist
log['u'] = log['u']
log['v'] = log['v']
return res, log
else:
return ot.gromov.cg(p, q, (1 - alpha) * M, alpha, f, df, G0, armijo=armijo, C1=C1, C2=C2, constC=constC, **kwargs)

if ot.__version__ < '0.9.0':
return ot.gromov.cg(p, q, (1 - alpha) * M, alpha, f, df, G0, armijo=armijo, C1=C1, C2=C2, constC=constC, **kwargs)
else:
return ot.optim.cg(p, q, (1 - alpha) * M, alpha, f, df, G0, armijo=armijo, C1=C1, C2=C2, constC=constC, **kwargs)

3 changes: 3 additions & 0 deletions omicverse/utils/_roe.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ def roe(
f"Some expected frequencies are less than {expected_value_threshold}, it is suggested to use other statistical methods, such as Fisher's exact test")
expected_data = pd.DataFrame(expected, index=num_cell.index, columns=num_cell.columns)
adata.uns['expected_values'] = expected_data
roe = num_cell / expected_data
adata.uns['roe_results'] = roe
adata.uns['unsig_roe_results'] = roe
else:
print("P-value is greater than 0.05, there is no statistical significance")
roe_ratio = num_cell / expected
Expand Down
6 changes: 5 additions & 1 deletion omicverse_guide/docs/Release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,17 @@ Support Raw Windows platform
### Pl Module

- Fixed the 'celltyep_key' error of `ov.pl.cpdb_group_heatmap` #109
- Fixed an error in `ov.utils.roe` when some expected frequencies are less than expected value.

### Single Module
- Fixed the bug of `ov.single.cytotrace2` when adata.X is not sparse data. #115, #116

### Bulk Module

- Fixed an key error in `ov.bulk.Matrix_ID_mapping`
- Added `enrichment_multi_concat` in `ov.bulk` to concat the result of enrichment.

### Bulk Module
### Bulk2Single Module

- Added `adata.var_names_make_unique()` to avoid mat shape error if gene not unique. #100

Expand Down

0 comments on commit b520a0d

Please sign in to comment.