pySCENIC 与 SciPy 高版本兼容问题修复

pySCENIC 与 SciPy 高版本兼容问题修复


pySCENIC:对新 SciPy 的兼容性修复

python - <<'PY'
from pathlib import Path
SP = Path("/share/biosoft/python/Python-v3.10.10/lib/python3.10/site-packages")
def sub(path, old, new):
    s = path.read_text()
    if new in s:
        print("already patched:", path)
        return
    if old not in s:
        raise SystemExit(f"pattern not found: {path}")
    path.write_text(s.replace(old, new, 1))
    print("patched:", path)
sub(SP / "arboreto/core.py",
"""    if isinstance(target_gene_expression, scipy.sparse.spmatrix):
        target_gene_expression = target_gene_expression.A.flatten()""",
"""    if scipy.sparse.issparse(target_gene_expression):
        target_gene_expression = target_gene_expression.toarray().ravel()""")
sub(SP / "pyscenic/utils.py",
"""    # Create numpy array of idx pairs.
    return np.array(
        [
            [symbol2idx[s1], symbol2idx[s2]]
            for s1, s2 in zip(adjacencies.TF, adjacencies.target)
        ]
    )""",
"""    # Create numpy array of idx pairs (int64, C-contiguous for the numba kernel).
    pairs = [
        [symbol2idx[s1], symbol2idx[s2]]
        for s1, s2 in zip(adjacencies.TF, adjacencies.target)
    ]
    return np.ascontiguousarray(pairs, dtype=np.int64).reshape(-1, 2)""")
sub(SP / "pyscenic/utils.py",
"        rhos = masked_rho4pairs(ex_mtx.values, col_idx_pairs, 0.0)",
"""        rhos = masked_rho4pairs(
            np.ascontiguousarray(ex_mtx.values, dtype=np.float64),
            col_idx_pairs,
            0.0,
        )""")
PY


  • 发表于 1天前
  • 阅读 ( 21 )
  • 分类:转录组

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
omicsgene
omicsgene

生物信息

810 篇文章

作家榜 »

  1. omicsgene 810 文章
  2. 安生水 372 文章
  3. Daitoue 167 文章
  4. 生物女学霸 120 文章
  5. xun 98 文章
  6. rzx 88 文章
  7. Ti Amo 81 文章
  8. 红橙子 81 文章