-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update scvelo default branch Update default branch from `master` to `main`. * Update `ci.yml` Update branches triggering CI.
- Loading branch information
Showing
11 changed files
with
76 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import numpy as np | ||
|
||
import scvelo as scv | ||
|
||
adata = scv.datasets.pancreas(file_path="data/pancreas.h5ad") | ||
obs_names = adata.obs_names.tolist() | ||
obs_names[0] = f"blah-{obs_names[0]}" | ||
obs_names[1] = f"blah-{obs_names[0]}" | ||
adata.obs_names = obs_names | ||
|
||
bdata = adata.copy() | ||
bdata.obs_names = np.arange(0, bdata.n_obs).astype(str) | ||
|
||
adata = scv.utils.merge(adata, bdata) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import os | ||
from pathlib import Path | ||
from urllib.request import urlretrieve | ||
|
||
import numpy as np | ||
import pandas as pd | ||
|
||
|
||
def load(filename, backup_url=None, header="infer", index_col="infer", **kwargs): | ||
"""Load a csv, txt, tsv or npy file.""" | ||
numpy_ext = {"npy", "npz"} | ||
pandas_ext = {"csv", "txt", "tsv"} | ||
|
||
if not os.path.exists(filename) and backup_url is None: | ||
raise FileNotFoundError(f"Did not find file {filename}.") | ||
|
||
elif not os.path.exists(filename): | ||
d = os.path.dirname(filename) | ||
if not os.path.exists(d): | ||
os.makedirs(d) | ||
urlretrieve(backup_url, filename) | ||
|
||
ext = Path(filename).suffixes[-1][1:] | ||
|
||
if ext in numpy_ext: | ||
return np.load(filename, **kwargs) | ||
|
||
elif ext in pandas_ext: | ||
df = pd.read_csv( | ||
filename, | ||
header=header, | ||
index_col=None if index_col == "infer" else index_col, | ||
**kwargs, | ||
) | ||
if index_col == "infer" and len(df.columns) > 1: | ||
is_int_index = all(np.arange(0, len(df)) == df.iloc[:, 0]) | ||
is_str_index = isinstance(df.iloc[0, 0], str) and all( | ||
[not isinstance(d, str) for d in df.iloc[0, 1:]] | ||
) | ||
if is_int_index or is_str_index: | ||
df.set_index(df.columns[0], inplace=True) | ||
return df | ||
|
||
else: | ||
raise ValueError( | ||
f"'{filename}' does not end on a valid extension.\n" | ||
"Please, provide one of the available extensions.\n" | ||
f"{numpy_ext | pandas_ext}\n" | ||
) | ||
|
||
|
||
read_csv = load |