
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
이러한 에러가 반복적으로 떠서 chat gpt에게 질문도 해보았으나,
전혀 해결되지 않습니다.
scanpy라는 라이브러리 사용해서 분석하고 있는데,
혹시 해결 방법 알고 계시면 해결 부탁드립니다 ㅠㅠ

# %%
# Core scverse libraries
import scanpy as sc
import anndata as ad
import numpy as np
# Data retrieval
import pooch
# %%
sc.settings.set_figure_params(dpi=50, facecolor="white")
# %%
EXAMPLE_DATA = pooch.create(
path=pooch.os_cache("scverse_tutorials"),
base_url="doi:10.6084/m9.figshare.22716739.v1/",
)
EXAMPLE_DATA.load_registry_from_doi()
# %%
samples = {
"s1d1": "s1d1_filtered_feature_bc_matrix.h5",
"s1d3": "s1d3_filtered_feature_bc_matrix.h5",
}
adatas = {}
for sample_id, filename in samples.items():
path = EXAMPLE_DATA.fetch(filename)
sample_adata = sc.read_10x_h5(path)
sample_adata.var_names_make_unique()
adatas[sample_id] = sample_adata
adata = ad.concat(adatas, label="sample")
adata.obs_names_make_unique()
# %%
# mitochondrial genes, "MT-" for human, "Mt-" for mouse
adata.var["mt"] = adata.var_names.str.startswith("MT-")
# ribosomal genes
adata.var["ribo"] = adata.var_names.str.startswith(("RPS", "RPL"))
# hemoglobin genes
adata.var["hb"] = adata.var_names.str.contains("^HB[^(P)]")
# %%
sc.pp.calculate_qc_metrics(
adata, qc_vars=["mt", "ribo", "hb"], inplace=True, log1p=True
)
# %%
sc.pl.violin(
adata,
["n_genes_by_counts", "total_counts", "pct_counts_mt"],
jitter=0.4,
multi_panel=True,
)
# %%
sc.pl.scatter(adata, "total_counts", "n_genes_by_counts", color="pct_counts_mt")
# %%
sc.pp.filter_cells(adata, min_genes=100)
sc.pp.filter_genes(adata, min_cells=3)
# %%
sc.pp.scrublet(adata, batch_key="sample")
# %%
# Saving count data
adata.layers["counts"] = adata.X.copy()
# %%
# Normalizing to median total counts
sc.pp.normalize_total(adata)
# Logarithmize the data
sc.pp.log1p(adata)
# %%
sc.pp.highly_variable_genes(adata, n_top_genes=2000, batch_key="sample")
# %%
sc.pl.highly_variable_genes(adata)
# %%
sc.tl.pca(adata)
# %%
sc.pl.pca_variance_ratio(adata, n_pcs=50, log=True)
# %%
sc.pl.pca(
adata,
color=["sample", "sample", "pct_counts_mt", "pct_counts_mt"],
dimensions=[(0, 1), (2, 3), (0, 1), (2, 3)],
ncols=2,
size=2,
)
# %%
sc.pp.neighbors(adata)
# %%
sc.tl.umap(adata)
# %%
sc.pl.umap(
adata,
color="sample",
# Setting a smaller point size to get prevent overlap
size=2,
)
# %%
random_state = np.random.randint(0, high=2 ** 32 - 2, dtype=np.int64)
# %%
import numpy as np
# Example where high is corrected to fit within int32 bounds
random_number = np.random.randint(low=0, high=2**31, size=1)
# %%
import numpy as np
low = 0
high = 2**31 - 1 # Maximum value for a 32-bit signed integer
rand_int = np.random.randint(low, high)
# %%
import numpy as np
low = 0
high = 2**31 - 1 # Maximum value for a 32-bit signed integer
rand_int = np.random.randint(low, high)
# %%
import random
low = 0
high = 10**10 # Example of a larger range
rand_int = random.randint(low, high)
# %%
import numpy as np
def safe_randint(low, high):
if not (-2**31 <= high < 2**31):
raise ValueError("The value of 'high' is out of bounds for int32")
return np.random.randint(low, high)
low = 0
high = 2**31 - 1 # Example high value within bounds
try:
rand_int = safe_randint(low, high)
print(f"Random integer: {rand_int}")
except ValueError as e:
print(e)
# %%
sc.tl.leiden(adata, flavor="igraph", n_iterations=2)
Exception ignored in: <class 'ValueError'>
Traceback (most recent call last):
File "numpy\\random\\mtrand.pyx", line 780, in numpy.random.mtrand.RandomState.randint
File "numpy\\random\\_bounded_integers.pyx", line 2881, in numpy.random._bounded_integers._rand_int32
ValueError: high is out of bounds for int32
