Coder Social home page Coder Social logo

cellfm's Introduction

We propose a single-cell foundation model, CellFM.

CellFM

The official implementation for "CellFM".

Table of Contents

Datasets

We provide an easy access to the used datasets in the synapse.

Installation

To reproduce CellFM, we suggest first create a conda environment by:

conda create -n cellFM python=3.9
conda activate cellFM

and then install the required packages below:

  • mindspore=2.2.10
  • scanpy=1.10

optional

  • gears
  • torch

Usage

data preprocessing

To run CellFM, we need to first preprocess the data in h5 or h5ad format. The preprocess pipeline for different downstream tasks can refer process.ipynb. We recommond storing the processed datasets in datasets directory.

Train on new dataset

We provided a script train.py for finetuning or training on new datasets. For example, we can train on HumanPBMC dataset with single NPU device by execute:

# Train with single device
python train.py --data HumanPBMC --batch 4 --epoch 5 --load_pretrain [--fp16] [--lora LORA_RANK] [--workpath /DIR/TO/WORKSPACE]
  • --data: dataset name. Note that the dataset should be located in /DIR/TO/WORKSPACE/datasets with h5 or h5ad format.
  • --batch: batch size.
  • --epoch: the number of training epoch.
  • --load_pretrain: load the pretrained weight of CellFM.
  • --fp16: unnecessary. Set training process under half-precision mode.
  • --lora: unnecessary. Using LoRA algorithm to update the weights using LORA_RANK as the hidden dimension of lora block, default 0 i.e. not use LoRA.
  • --workpath: unnecessary when train with single device. Set the absolute directory of work path, default the directory containing codes.

We also provide a script to apply parallelly training within one node. For the same example, the command below works the same as the command above except it will works on 8 devices while each device handle an input with batch size=4.

# Train parallelly in one node
bash 1node_train.sh train 4 5 HumanPBMC

Tutorial

Tutorial 1: Cell Annotation

See CellAnnotation.ipynb.

Tutorial 2: Gene Function Prediction

See GeneFunction.ipynb.

Citation

If you find our codes useful, please consider citing our work:

@article{CellFM,
  title={CellFM: a large-scale foundation model pre-trained on transcriptomics of 100 million human cells},
  author={Yuansong Zeng, Jiancong Xie, Zhuoyi Wei, Yun Su, Ningyuan Shangguan, Shuangyu Yang, Chengyang Zhang, Wenbing Li, Jinbo Zhang, Nan Fang, Hongyu Zhang, Huiying Zhao, Yutong Lu, Jue Fan, Weijiang Yu, and Yuedong Yang},
  journal={},
  year={2024},
}

cellfm's People

Contributors

utopiafable avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.