Instructions to use ctheodoris/Geneformer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ctheodoris/Geneformer with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="ctheodoris/Geneformer")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained("ctheodoris/Geneformer") model = AutoModelForMaskedLM.from_pretrained("ctheodoris/Geneformer", device_map="auto") - Inference
- Notebooks
- Google Colab
- Kaggle
Christina Theodoris commited on
Commit ·
f75f5ac
1
Parent(s): b294421
Update readthedocs for classifier
Browse filesFiles changed (3)
5 unmodified lines67895 unmodified lines:undoc-members::show-inheritance::exclude-members:validate_options5 unmodified lines6789105 unmodified lines:undoc-members::show-inheritance::exclude-members:valid_option_dict,validate_options
2 unmodified lines3456789101112131415162 unmodified lines**Input data:**Cell state classifier:| Single-cell transcriptomes as Geneformer rank value encodings with cell state labels| in Geneformer .dataset format (generated from single-cell RNAseq data by tokenizer.py)Gene classifier:| Dictionary in format {Gene_label: list(genes)} for gene labels| and single-cell transcriptomes as Geneformer rank value encodings| in Geneformer .dataset format (generated from single-cell RNAseq data by tokenizer.py)**Usage:**2 unmodified lines3456789101112132 unmodified lines**Input data:**| Cell state classifier:| Single-cell transcriptomes as Geneformer rank value encodings with cell state labels in Geneformer .dataset format (generated from single-cell RNAseq data by tokenizer.py)| Gene classifier:| Dictionary in format {Gene_label: list(genes)} for gene labels and single-cell transcriptomes as Geneformer rank value encodings in Geneformer .dataset format (generated from single-cell RNAseq data by tokenizer.py)**Usage:**
88 unmodified lines899091929394952 unmodified lines989910010110210310410510610710810911011111235 unmodified lines1481491501511521531544 unmodified lines15916016116216316488 unmodified lines):"""Initialize tokenizer.**Parameters:**custom_attr_name_dict : None, dict| Dictionary of custom attributes to be added to the dataset.| Keys are the names of the attributes in the loom file.2 unmodified lines| Number of processes to use for dataset mapping.chunk_size : int = 512| Chunk size for anndata tokenizer.model_input_size: int = 2048| Max input size of model to truncate input to.special_token: bool = False| Option to add CLS and SEP tokensgene_median_file : Path| Path to pickle file containing dictionary of non-zero median| gene expression values across Genecorpus-30M.token_dictionary_file : Path| Path to pickle file containing token dictionary (Ensembl IDs:token)."""# dictionary of custom attributes {output dataset column name: input .loom column name}self.custom_attr_name_dict = custom_attr_name_dict35 unmodified lines):"""Tokenize .loom files in data_directory and save as tokenized .dataset in output_directory.**Parameters:**data_directory : Path| Path to directory containing loom files or anndata filesoutput_directory : Path4 unmodified lines| Format of input files. Can be "loom" or "h5ad".use_generator : bool| Whether to use generator or dict for tokenization."""tokenized_cells, cell_metadata = self.tokenize_files(Path(data_directory), file_format88 unmodified lines8990919293949596972 unmodified lines10010110210310410510610710810911011111211311411535 unmodified lines1511521531541551561571581594 unmodified lines16416516616716816917088 unmodified lines):"""Initialize tokenizer.**Parameters:**custom_attr_name_dict : None, dict| Dictionary of custom attributes to be added to the dataset.| Keys are the names of the attributes in the loom file.2 unmodified lines| Number of processes to use for dataset mapping.chunk_size : int = 512| Chunk size for anndata tokenizer.model_input_size : int = 2048| Max input size of model to truncate input to.special_token : bool = False| Adds CLS token before and SEP token after rank value encoding.gene_median_file : Path| Path to pickle file containing dictionary of non-zero median| gene expression values across Genecorpus-30M.token_dictionary_file : Path| Path to pickle file containing token dictionary (Ensembl IDs:token)."""# dictionary of custom attributes {output dataset column name: input .loom column name}self.custom_attr_name_dict = custom_attr_name_dict35 unmodified lines):"""Tokenize .loom files in data_directory and save as tokenized .dataset in output_directory.**Parameters:**data_directory : Path| Path to directory containing loom files or anndata filesoutput_directory : Path4 unmodified lines| Format of input files. Can be "loom" or "h5ad".use_generator : bool| Whether to use generator or dict for tokenization."""tokenized_cells, cell_metadata = self.tokenize_files(Path(data_directory), file_format
docs/source/geneformer.classifier.rst+1
geneformer/classifier.py+5-8
geneformer/tokenizer.py+9-3