diff --git a/dance/transforms/filter.py b/dance/transforms/filter.py index 8ec0ac1f..ef703d0d 100644 --- a/dance/transforms/filter.py +++ b/dance/transforms/filter.py @@ -274,6 +274,20 @@ def __init__( @register_preprocessor("filter", "cell") @add_mod_and_transform class FilterCellsCommonMod(BaseTransform): + """Initialize the FilterCellsCommonMod class. + + Parameters + ---------- + mod1 : str + Name of the first modality in the single-cell dataset. + mod2 : str + Name of the second modality in the single-cell dataset. + sol : Optional[str], default=None + Name of the optional solution dataset containing cell labels or annotations. + **kwargs : dict + Additional keyword arguments passed to the base transformation class. + + """ def __init__(self, mod1: str, mod2: str, sol: Optional[str] = None, **kwargs): super().__init__(**kwargs) diff --git a/dance/utils/wrappers.py b/dance/utils/wrappers.py index 28ffefe8..a7f308ee 100644 --- a/dance/utils/wrappers.py +++ b/dance/utils/wrappers.py @@ -95,6 +95,8 @@ def wrapped_func(*args): def add_mod_and_transform(cls): + """A decorator that modifies a class to add functionality for working with specific + modalities (`mod`) in a `mudata` object.""" original_init = cls.__init__ original_call = cls.__call__ cls.add_mod_and_transform = "add_mod_and_transform" @@ -107,6 +109,16 @@ def new_init(self, *args, **kwargs): @functools.wraps(original_call) def new_call(self, data: Data, *args, **kwargs): + """ + Parameters + ---------- + data : Data + The input data object containing the `mudata` with multiple modalities. + Returns + ------- + Any + The result of the original_call method. + """ if hasattr(self, 'mod') and self.mod is not None: md_data = data.data ad_data = Data(data=transform_mod_to_anndata(md_data, self.mod)) diff --git a/examples/get_result_web.py b/examples/get_result_web.py index 891c98d9..c69e9d4e 100644 --- a/examples/get_result_web.py +++ b/examples/get_result_web.py @@ -16,22 +16,23 @@ def check_identical_strings(string_list): if not string_list: - raise ValueError("列表为空") + raise ValueError("The list is empty") arr = np.array(string_list) if not np.all(arr == arr[0]): - raise ValueError("发现不同的字符串") + raise ValueError("Different strings found") return string_list[0] - # if not string_list: - # raise ValueError("列表为空") + # raise ValueError("The list is empty") # first_string = string_list[0] # for s in string_list[1:]: # if s != first_string: - # raise ValueError(f"发现不同的字符串: '{first_string}' 和 '{s}'") + # raise ValueError(f"Different strings found: '{first_string}' and '{s}'") # return first_string + + def get_sweep_url(step_csv: pd.DataFrame, single=True): ids = step_csv["id"] sweep_urls = [] @@ -57,7 +58,7 @@ def spilt_web(url: str): if match: entity = match.group(1) project = match.group(2) - pattern = r'/sweeps/([^/?]+)' # 正则表达式模式 + pattern = r'/sweeps/([^/?]+)' # Regular expression pattern match = re.search(pattern, url) if match: sweep_id = match.group(1) @@ -161,8 +162,8 @@ def write_ans(tissue): step3_urls = [] for i in range(3): file_csv = f"{file_path}/results/params/{i}_best_test_acc.csv" - if not os.path.exists(file_csv): #no parameter - print(f"文件 {file_csv} 不存在,跳过。") + if not os.path.exists(file_csv): # no parameter + print(f"File {file_csv} does not exist, skipping.") continue step3_urls.append(get_sweep_url(pd.read_csv(file_csv))) step3_str = ",".join(step3_urls)