File size: 3,973 Bytes
f89f796 4302f48 f89f796 78dd83b 4302f48 d468697 4302f48 78dd83b e606e1c 78dd83b cb1b0d5 78dd83b f89f796 78dd83b f89f796 4302f48 f89f796 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
{
"cells": [
{
"cell_type": "markdown",
"id": "a91bca46-c056-4784-8c6c-b0f5d3f33496",
"metadata": {
"tags": []
},
"source": [
"## Tokenizing .loom or .h5ad single cell RNA-seq data to rank value encoding .dataset format"
]
},
{
"cell_type": "markdown",
"id": "350e6252-b783-494b-9767-f087eb868a15",
"metadata": {},
"source": [
"#### Input data is a directory with .loom or .h5ad files containing raw counts from single cell RNAseq data, including all genes detected in the transcriptome without feature selection. The input file type is specified by the argument file_format in the tokenize_data function.\n",
"\n",
"#### The discussion below references the .loom file format, but the analagous labels are required for .h5ad files, just that they will be column instead of row attributes and vice versa due to the transposed format of the two file types.\n",
"\n",
"#### Genes should be labeled with Ensembl IDs (loom row attribute \"ensembl_id\"), which provide a unique identifer for conversion to tokens. Other forms of gene annotations (e.g. gene names) can be converted to Ensembl IDs via Ensembl Biomart. Cells should be labeled with the total read count in the cell (loom column attribute \"n_counts\") to be used for normalization.\n",
"\n",
"#### No cell metadata is required, but custom cell attributes may be passed onto the tokenized dataset by providing a dictionary of custom attributes to be added, which is formatted as loom_col_attr_name : desired_dataset_col_attr_name. For example, if the original .loom dataset has column attributes \"cell_type\" and \"organ_major\" and one would like to retain these attributes as labels in the tokenized dataset with the new names \"cell_type\" and \"organ\", respectively, the following custom attribute dictionary should be provided: {\"cell_type\": \"cell_type\", \"organ_major\": \"organ\"}. \n",
"\n",
"#### Additionally, if the original .loom file contains a cell column attribute called \"filter_pass\", this column will be used as a binary indicator of whether to include these cells in the tokenized data. All cells with \"1\" in this attribute will be tokenized, whereas the others will be excluded. One may use this column to indicate QC filtering or other criteria for selection for inclusion in the final tokenized dataset.\n",
"\n",
"#### If one's data is in other formats besides .loom or .h5ad, one can use the relevant tools (such as Anndata tools) to convert the file to a .loom or .h5ad format prior to running the transcriptome tokenizer.\n",
"\n",
"#### OF NOTE: PLEASE ENSURE THE CORRECT TOKEN DICTIONARY AND GENE MEDIAN FILE IS USED FOR THE CORRECT MODEL.\n",
"\n",
"#### The 95M model series also require the special_token argument to be set to True."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "080fdd9c-0c48-4d5d-a254-52b6c53cdf78",
"metadata": {},
"outputs": [],
"source": [
"from geneformer import TranscriptomeTokenizer"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "37205758-aa52-4443-a383-0638519ee8a9",
"metadata": {},
"outputs": [],
"source": [
"tk = TranscriptomeTokenizer({\"cell_type\": \"cell_type\", \"organ_major\": \"organ\"}, nproc=16)\n",
"tk.tokenize_data(\"loom_data_directory\", \n",
" \"output_directory\", \n",
" \"output_prefix\", \n",
" file_format=\"loom\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|