Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Celltype annotation automl #423

Merged
merged 342 commits into from
Jun 17, 2024
Merged

Celltype annotation automl #423

merged 342 commits into from
Jun 17, 2024

Conversation

xingzhongyu
Copy link
Collaborator

@xingzhongyu xingzhongyu commented Feb 20, 2024

Complete the automl task about celltype_annotation. Currently, for each celltype annotation algorithm task, a data set is arbitrarily selected for a full set run. Due to the merge time problem, it does not end completely, but it is close to the complete run. I will wait until this merge is completed before resuming operation.

dance/pipeline.py Outdated Show resolved Hide resolved
@@ -835,6 +849,22 @@ def save_summary_data(entity, project, sweep_id, summary_file_path):
result.update({"id": run.id})
summary_data.append(flatten_dict(result)) # get result and config
ans = pd.DataFrame(summary_data).set_index(["id"])
conf = OmegaConf.load(conf_load_path)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the column names of the summary table

for x in row:
for k in conf.pipeline:
if k["target"] == x:
pipeline.append(k)
for i, f in zip(required_indexes, required_funs):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some necessary functions, such as setConfig, can be obtained from the yaml of step 2 instead of the default yaml of step 3.

count += 1


def run_step3(MAINDIR, evaluate_pipeline, step2_pipeline_planer: PipelinePlaner, tune_mode="params", sweep_id=None):
Copy link
Collaborator Author

@xingzhongyu xingzhongyu Feb 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The step3 function is run by default

parser = argparse.ArgumentParser()
parser.add_argument("--batch_size", type=int, default=500)
parser.add_argument("--cache", action="store_true", help="Cache processed data.")
# parser.add_argument("--dense_dim", type=int, default=400, help="number of hidden gcn units")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are hyperparameters that both the preprocessing function and the model depend on. Delete them and read them through the configuration file.

parser.add_argument("--valid_dataset", nargs="+", default=[1970], help="List of valid dataset ids.")
parser.add_argument("--seed", type=int, default=0, help="Initial seed random, offset for each repeatition")

parser.add_argument("--tune_mode", default="pipeline_params", choices=["pipeline", "params", "pipeline_params"])
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add some parameters

parser.add_argument("--log_level", type=str, default="INFO", choices=get_args(LogLevel))
parser.add_argument("--species", default="mouse")
parser.add_argument("--test_dataset", nargs="+", default=[2695], type=int, help="list of dataset id")
parser.add_argument("--tissue", default="Brain") # TODO: Add option for different tissue name for train/test
parser.add_argument("--train_dataset", nargs="+", default=[753], type=int, help="list of dataset id")
parser.add_argument("--valid_dataset", nargs="+", default=[3285], type=int, help="list of dataset id")
parser.add_argument("--tune_mode", default="pipeline", choices=["pipeline", "params"])
parser.add_argument("--tune_mode", default="pipeline_params", choices=["pipeline", "params", "pipeline_params"])
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add new tune_mode

self.train2valid()

def train2valid(self):
logger.info("Copy train_dataset and use it as valid_dataset")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

train_dataset can be used as valid_dataset when needed

n_cells: Optional[int] = None,
bin_size: int = 500,
bw_adjust: float = 3,
processes_num=os.cpu_count(),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number of processes needs to be parameterized

args = parser.parse_args()
logger.setLevel(args.log_level)
logger.info(f"\n{pprint.pformat(vars(args))}")
MAINDIR = Path(__file__).resolve().parent
pipeline_planer = PipelinePlaner.from_config_file(f"{MAINDIR}/{args.config_dir}{args.tune_mode}_tuning_config.yaml")
file_root_path = Path(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the name of the data set is used as the folder, and the name of the biological tissue can also be used.



def run_step3(root_path, evaluate_pipeline, step2_pipeline_planer: PipelinePlaner, tune_mode="params"):
"""Run step 3 by default.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run step 3 by default.

xingzhongyu and others added 28 commits May 26, 2024 11:55
Copy link
Collaborator

@RemyLau RemyLau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -117,6 +117,27 @@ def __call__(self, data):
data.data.raw = data.data.copy()


@register_preprocessor("misc")
class UpdateRaw(BaseTransform):
"""Update raw data.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UpdateRaw is confusing. Change to something like AlignRaw to more accurately reflect its function.

@JiayuanDing100 JiayuanDing100 merged commit 3620ce1 into main Jun 17, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants