### Install TOSICA Package from GitHub Source: https://github.com/jackiehanlab/tosica/blob/main/README.md Installs the TOSICA Python package directly from its GitHub repository. ```bash pip install git+https://github.com/JackieHanLab/TOSICA.git ``` -------------------------------- ### Install TOSICA Package Locally Source: https://github.com/jackiehanlab/tosica/blob/main/README.md Installs the TOSICA Python package from the local repository root. ```bash pip install . ``` -------------------------------- ### Check PyTorch and CUDA Version Source: https://github.com/jackiehanlab/tosica/blob/main/test/tutorial.ipynb Verifies the installed PyTorch version and CUDA capabilities, essential for GPU acceleration. ```python import torch print(torch.__version__) print(torch.cuda.get_device_capability(device=None), torch.cuda.get_device_name(device=None)) ``` -------------------------------- ### Initialize Environment Source: https://github.com/jackiehanlab/tosica/blob/main/reproducibility/Fig4.ipynb Imports necessary libraries and configures global settings for Scanpy plotting. ```python import scanpy as sc import os import math import itertools import warnings import numpy as np import pandas as pd import matplotlib.pyplot as plt import anndata sc.settings.set_figure_params(dpi_save=600, frameon=False, transparent=True, fontsize=10) warnings.filterwarnings('ignore') ``` -------------------------------- ### Fine-tune with pre-trained weights Source: https://context7.com/jackiehanlab/tosica/llms.txt Initializes the model with existing weights to perform transfer learning on new datasets. ```python import TOSICA import scanpy as sc ref_adata = sc.read('new_reference_data.h5ad') # Fine-tune from pre-trained weights TOSICA.train( adata=ref_adata, gmt_path='human_gobp', label_name='Celltype', project='finetuned_model', pre_weights='./pretrained_model/model-5.pth', # Path to pre-trained weights epochs=5 ) ``` -------------------------------- ### TOSICA Training with Pre-weights Output Source: https://github.com/jackiehanlab/tosica/blob/main/test/tutorial.ipynb Shows the training progress and validation metrics for a single epoch when using pre-trained weights. ```text [train epoch 0] loss: 0.153, acc: 0.974: 100%|██████████| 5096/5096 [01:32<00:00, 55.28it/s] [valid epoch 0] loss: 0.040, acc: 0.992: 100%|██████████| 5096/5096 [00:31<00:00, 162.61it/s] ``` -------------------------------- ### Create Conda Environment for TOSICA Source: https://github.com/jackiehanlab/tosica/blob/main/README.md Sets up a Conda environment with Python 3.8, scanpy, and specific PyTorch versions required for TOSICA. ```bash conda create -n TOSICA python=3.8 scanpy conda activate TOSICA conda install pytorch=1.7.1 torchvision=0.8.2 torchaudio=0.7.2 cudatoolkit=10.1 -c pytorch ``` -------------------------------- ### TOSICA Training Output Files Source: https://github.com/jackiehanlab/tosica/blob/main/test/tutorial.ipynb Lists the files generated after training, including model weights, pathway information, and label dictionaries. ```text Training finished! label_dictionary.csv mask.npy model-0.pth model-1.pth model-2.pth pathway.csv ``` -------------------------------- ### Import Libraries Source: https://github.com/jackiehanlab/tosica/blob/main/test/tutorial.ipynb Imports necessary libraries for TOSICA and general data analysis. Suppresses warnings for cleaner output. ```python import TOSICA import scanpy as sc import numpy as np import warnings warnings.filterwarnings ("ignore") ``` -------------------------------- ### Copy Pre-trained Weights Source: https://github.com/jackiehanlab/tosica/blob/main/test/tutorial.ipynb Copies a pre-trained model weight file to be used for fine-tuning or transfer learning. ```bash !cp ./hGOBP_demo/model-0.pth ./pre_weights.pth ``` -------------------------------- ### Load Data Source: https://github.com/jackiehanlab/tosica/blob/main/reproducibility/Fig4.ipynb Reads the raw h5ad file into an AnnData object. ```python adata = sc.read('./Fig4_raw.h5ad') adata ``` -------------------------------- ### Preprocess Data for Visualization Source: https://github.com/jackiehanlab/tosica/blob/main/test/tutorial.ipynb Applies standard preprocessing steps using scanpy, including normalization, log transformation, scaling, PCA, neighbor graph construction, and UMAP dimensionality reduction. ```python new_adata.raw = new_adata sc.pp.normalize_total(new_adata, target_sum=1e4) sc.pp.log1p(new_adata) sc.pp.scale(new_adata, max_value=10) sc.tl.pca(new_adata, svd_solver='arpack') sc.pp.neighbors(new_adata, n_neighbors=10, n_pcs=40) sc.tl.umap(new_adata) ``` -------------------------------- ### Complete TOSICA Training and Prediction Pipeline Source: https://context7.com/jackiehanlab/tosica/llms.txt A full workflow demonstrating data loading, model training, prediction, and visualization. Ensure gene alignment between reference and query datasets is critical. ```python import TOSICA import scanpy as sc import warnings warnings.filterwarnings("ignore") # Load and inspect reference data ref_adata = sc.read('demo_train.h5ad') print(f"Reference: {ref_adata.n_obs} cells × {ref_adata.n_vars} genes") print(ref_adata.obs['Celltype'].value_counts()) # Load query data and align genes to reference query_adata = sc.read('demo_test.h5ad') query_adata = query_adata[:, ref_adata.var_names] # Critical: match gene order print(f"Query: {query_adata.n_obs} cells × {query_adata.n_vars} genes") # Train model with human GO biological processes TOSICA.train( ref_adata, gmt_path='human_gobp', label_name='Celltype', project='pancreas_gobp', epochs=10 ) # Select best model (typically last epoch or based on validation accuracy) model_path = './pancreas_gobp/model-9.pth' # Predict cell types on query data new_adata = TOSICA.pre( query_adata, model_weight_path=model_path, project='pancreas_gobp' ) # Evaluate prediction accuracy if 'Celltype' in new_adata.obs.columns: accuracy = (new_adata.obs['Prediction'] == new_adata.obs['Celltype']).mean() print(f"Prediction accuracy: {accuracy:.3f}") # Generate UMAP visualization new_adata.raw = new_adata sc.pp.normalize_total(new_adata, target_sum=1e4) sc.pp.log1p(new_adata) sc.pp.scale(new_adata, max_value=10) sc.tl.pca(new_adata) sc.pp.neighbors(new_adata, n_neighbors=10, n_pcs=40) sc.tl.umap(new_adata) sc.pl.umap(new_adata, color=['Celltype', 'Prediction', 'Probability']) # Save results new_adata.write('annotated_results.h5ad') ``` -------------------------------- ### Train TOSICA with Pre-trained Weights Source: https://github.com/jackiehanlab/tosica/blob/main/test/tutorial.ipynb Trains a TOSICA model using reference data and pre-trained weights, specifying the GMT pathway, label name, and number of epochs. Indicates successful loading of masks and model. ```python TOSICA.train(ref_adata, gmt_path='human_gobp', label_name='Celltype',pre_weights='pre_weights.pth',epochs=1) ``` -------------------------------- ### Train TOSICA Model Source: https://github.com/jackiehanlab/tosica/blob/main/test/tutorial.ipynb Trains a TOSICA model using the reference data, specifying the GMT pathway file, label name, number of epochs, and project name. Lists the contents of the output directory. ```python TOSICA.train(ref_adata, gmt_path='human_gobp', label_name='Celltype',epochs=3,project='hGOBP_demo') !ls ./hGOBP_demo ``` -------------------------------- ### TOSICA Model Training Output Source: https://github.com/jackiehanlab/tosica/blob/main/test/tutorial.ipynb Displays the training progress and validation metrics for each epoch, indicating loss and accuracy. ```text [train epoch 0] loss: 1.876, acc: 0.296: 100%|██████████| 5096/5096 [01:39<00:00, 51.10it/s] [valid epoch 0] loss: 0.305, acc: 0.967: 100%|██████████| 5096/5096 [00:34<00:00, 149.26it/s] [train epoch 1] loss: 0.168, acc: 0.975: 100%|██████████| 5096/5096 [01:40<00:00, 50.88it/s] [valid epoch 1] loss: 0.042, acc: 0.993: 100%|██████████| 5096/5096 [00:33<00:00, 152.25it/s] [train epoch 2] loss: 0.059, acc: 0.992: 100%|██████████| 5096/5096 [01:39<00:00, 51.08it/s] [valid epoch 2] loss: 0.024, acc: 0.996: 100%|██████████| 5096/5096 [00:33<00:00, 150.93it/s] ``` -------------------------------- ### Visualize Pathway Signaling with Scatter Plots Source: https://github.com/jackiehanlab/tosica/blob/main/reproducibility/Fig4.ipynb Generates a scatter plot to compare two specific Reactome pathways across cancer types. ```python sc.pl.scatter(sub, x='REACTOME_CYTOKINE_SIGNALING_IN_IMMUNE_SYSTEM', y='REACTOME_SIGNALING_BY_INSULIN_RECEPTOR', color='cancer', size=10, title='Macro_LYVE1',use_raw=True) ``` -------------------------------- ### Perform PCA, UMAP, and Louvain Clustering Source: https://github.com/jackiehanlab/tosica/blob/main/reproducibility/Fig4.ipynb This snippet preprocesses a subset of the AnnData object by scaling, performing PCA, computing nearest neighbors, and applying UMAP and Louvain clustering. It then visualizes the Louvain clusters on the UMAP plot. Ensure 'adata' is an AnnData object and 'Prebigtype' is a valid observation key. ```python sub = adata[adata.obs.Prebigtype=='Mono',:] #sc.pp.scale(sub, max_value=10) sc.tl.pca(sub, svd_solver='arpack') sc.pp.neighbors(sub, n_neighbors=10, n_pcs=50) sc.tl.umap(sub) sc.tl.louvain(sub,resolution=0.3, key_added='louvain_03') sc.pl.umap(sub, color='louvain_03', legend_loc='on data', frameon=False, legend_fontsize=10,title='louvain_03') ``` -------------------------------- ### Train TOSICA Model Source: https://github.com/jackiehanlab/tosica/blob/main/README.md Trains the TOSICA model using a reference AnnData object and a GMT file. The model and associated files are saved in a specified project directory. ```python TOSICA.train(ref_adata, gmt_path,project=,label_name=) ``` -------------------------------- ### Inspect Metadata Source: https://github.com/jackiehanlab/tosica/blob/main/reproducibility/Fig4.ipynb Checks the distribution of categorical metadata fields. ```python adata.obs.cancer.value_counts() ``` ```python adata.obs.bigtype.value_counts() ``` ```python adata.obs.Celltype.value_counts() ``` -------------------------------- ### TOSICA Training Finished Message Source: https://github.com/jackiehanlab/tosica/blob/main/test/tutorial.ipynb Confirms that the training process, potentially with pre-trained weights, has been completed. ```text Training finished! ``` -------------------------------- ### Load Query AnnData Source: https://github.com/jackiehanlab/tosica/blob/main/test/tutorial.ipynb Loads a query dataset using scanpy and aligns its genes with the reference AnnData. Displays the AnnData object and cell type value counts. ```python query_adata = sc.read('demo_test.h5ad') query_adata = query_adata[:,ref_adata.var_names] print(query_adata) print(query_adata.obs.Celltype.value_counts()) ``` -------------------------------- ### Configure Stage Categories and Colors Source: https://github.com/jackiehanlab/tosica/blob/main/reproducibility/Fig4.ipynb Converts the Stage observation to a categorical type and assigns custom hex color codes for visualization. ```python sub.obs.Stage = sub.obs.Stage.astype('category') sub.uns['Stage_colors'] = ["#BEBEBE", "#CE8E8E", "#DE5F5F" ,"#EE2F2F", "#FF0000"] ``` -------------------------------- ### PAGA Analysis Source: https://github.com/jackiehanlab/tosica/blob/main/reproducibility/Fig4.ipynb Performs PAGA analysis to visualize cluster connectivity. ```python sc.tl.paga(sub, groups='Precelltype') sc.pl.paga(sub, threshold=0.3, show=False,color='dpt_pseudotime') ``` -------------------------------- ### Analyze Gene-to-Token Weights Source: https://context7.com/jackiehanlab/tosica/llms.txt Load and analyze the gene-to-token weight matrix to identify key marker genes for specific pathways or pathways associated with a gene. Ensure the `gene2token_weights.csv` file is generated during prediction. ```python import pandas as pd import numpy as np # Load gene-to-token weights (generated during prediction) gene2token = pd.read_csv('./my_annotation_model/gene2token_weights.csv', index_col=0) # Find top genes for a specific pathway pathway_name = 'GOBP_IMMUNE_RESPONSE' if pathway_name in gene2token.index: pathway_weights = gene2token.loc[pathway_name].sort_values(ascending=False) top_genes = pathway_weights.head(20) print(f"Top genes for {pathway_name}:") print(top_genes) # Find pathways where a specific gene has highest weight gene_name = 'CD3D' if gene_name in gene2token.columns: gene_weights = gene2token[gene_name].sort_values(ascending=False) top_pathways = gene_weights.head(10) print(f"\nTop pathways involving {gene_name}:") print(top_pathways) ``` -------------------------------- ### Load Reference AnnData Source: https://github.com/jackiehanlab/tosica/blob/main/test/tutorial.ipynb Loads a reference dataset using scanpy and ensures it contains the same genes as the reference. Prints the AnnData object and cell type value counts. ```python ref_adata = sc.read('demo_train.h5ad') ref_adata = ref_adata[:,ref_adata.var_names] print(ref_adata) print(ref_adata.obs.Celltype.value_counts()) ``` -------------------------------- ### Train with custom gene sets Source: https://context7.com/jackiehanlab/tosica/llms.txt Uses a custom GMT file for pathway masks to allow domain-specific annotations during model training. ```python import TOSICA import scanpy as sc ref_adata = sc.read('reference_data.h5ad') # Train with custom GMT file containing domain-specific pathways TOSICA.train( adata=ref_adata, gmt_path='/path/to/custom_pathways.gmt', label_name='Celltype', project='custom_pathway_model', max_g=300, # Maximum genes per pathway max_gs=300, # Maximum number of pathways to include n_unannotated=1, # Number of fully connected tokens for unmapped genes epochs=10 ) ``` -------------------------------- ### Dimensionality Reduction and Visualization Source: https://github.com/jackiehanlab/tosica/blob/main/reproducibility/Fig4.ipynb Scales data, computes PCA, builds a neighbor graph, and generates UMAP plots. ```python sc.pp.scale(adata) sc.tl.pca(adata, svd_solver='arpack') sc.pp.neighbors(adata, n_neighbors=10, n_pcs=40) sc.tl.umap(adata) sc.pl.umap(adata, color='Celltype',edgecolor="none",show=False) sc.pl.umap(adata, color='Precelltype',edgecolor="none",show=False) ``` -------------------------------- ### Save and Display Predictions Source: https://github.com/jackiehanlab/tosica/blob/main/test/tutorial.ipynb Saves the AnnData object with predictions to a file and displays the resulting AnnData object, showing the new 'Prediction' and 'Probability' observation columns. ```python new_adata.write('demo_attn.h5ad') new_adata ``` -------------------------------- ### Analyze Attention Matrices with Scanpy Source: https://context7.com/jackiehanlab/tosica/llms.txt Visualize pathway contributions and create UMAP embeddings based on attention features. Requires prior prediction to generate the `new_adata` object. ```python import TOSICA import scanpy as sc import numpy as np # After prediction new_adata = TOSICA.pre(query_adata, model_weight_path='./model/model-5.pth', project='model') # Preserve raw attention scores new_adata.raw = new_adata # Preprocess attention matrix for visualization sc.pp.normalize_total(new_adata, target_sum=1e4) sc.pp.log1p(new_adata) sc.pp.scale(new_adata, max_value=10) # Compute UMAP embedding based on pathway attention sc.tl.pca(new_adata, svd_solver='arpack') sc.pp.neighbors(new_adata, n_neighbors=10, n_pcs=40) sc.tl.umap(new_adata) # Visualize predictions vs ground truth sc.pl.umap(new_adata, color=['Celltype', 'Prediction'], legend_loc='on data') # Visualize specific pathway attention scores sc.pl.umap(new_adata, color=['GOBP_IMMUNE_RESPONSE', 'GOBP_CELL_CYCLE']) # Heatmap of top pathways per cell type sc.tl.rank_genes_groups(new_adata, 'Prediction', method='wilcoxon') sc.pl.rank_genes_groups_heatmap(new_adata, n_genes=10) ``` -------------------------------- ### Train a TOSICA model Source: https://context7.com/jackiehanlab/tosica/llms.txt Trains a transformer model on a reference dataset using predefined gene set masks. Requires an AnnData object with cell-type labels. ```python import TOSICA import scanpy as sc # Load reference dataset with cell type labels ref_adata = sc.read('reference_data.h5ad') # Train with pre-configured human Gene Ontology biological process mask TOSICA.train( adata=ref_adata, gmt_path='human_gobp', # Options: human_gobp, human_immune, human_reactome, human_tf, mouse_gobp, mouse_reactome, mouse_tf label_name='Celltype', # Column name in adata.obs containing cell type labels project='my_annotation_model', # Output folder name epochs=10, batch_size=8, embed_dim=48, depth=2, num_heads=4, lr=0.001 ) # Output files created in ./my_annotation_model/: # - mask.npy: Pathway-gene mask matrix # - pathway.csv: List of pathways/gene sets used # - label_dictionary.csv: Cell type label encoding # - model-{epoch}.pth: Model weights for each epoch ``` -------------------------------- ### Generate UMAP Visualization Source: https://github.com/jackiehanlab/tosica/blob/main/test/tutorial.ipynb Generates a UMAP plot colored by 'Celltype' and 'Prediction' from the AnnData object, with the legend placed on the plot. ```python sc.pl.umap(new_adata, color=['Celltype', 'Prediction'],legend_loc='on data') ``` -------------------------------- ### Normalize and Log-transform Source: https://github.com/jackiehanlab/tosica/blob/main/reproducibility/Fig4.ipynb Performs total count normalization and log transformation on the AnnData object. ```python sc.pp.normalize_total(adata, target_sum=1e4) sc.pp.log1p(adata) adata.raw = adata ``` -------------------------------- ### Display Top 20 Correlations Source: https://github.com/jackiehanlab/tosica/blob/main/reproducibility/Fig4.ipynb Displays the top 20 gene pathways with the highest Spearman correlation coefficients with age, along with their corresponding p-values. ```python rcc[0:20] ``` -------------------------------- ### Predict Cell Types with TOSICA Source: https://github.com/jackiehanlab/tosica/blob/main/test/tutorial.ipynb Uses a trained TOSICA model to predict cell types for the query data. Specifies the model weight path and project name. Shows the device and number of cells processed. ```python model_weight_path = './hGOBP_demo/model-0.pth' new_adata = TOSICA.pre(query_adata, model_weight_path = model_weight_path,project='hGOBP_demo') ``` -------------------------------- ### TOSICA.train Source: https://github.com/jackiehanlab/tosica/blob/main/README.md Trains the TOSICA model using a reference AnnData object and a gene set mask. ```APIDOC ## TOSICA.train ### Description Trains the Transformer model for cell-type annotation based on a reference dataset and a specified gene set mask. ### Parameters #### Request Body - **ref_adata** (AnnData) - Required - An AnnData object of the reference dataset. - **gmt_path** (string) - Required - Path to .gmt files or a pre-prepared mask name. - **project** (string) - Optional - Name of the project folder to save model outputs. - **label_name** (string) - Required - The name of the label column in ref_adata.obs. ### Response - **mask.npy** (file) - Mask matrix. - **pathway.csv** (file) - Gene set list. - **label_dictionary.csv** (file) - Label list. - **model-n.pth** (file) - Model weights. ``` -------------------------------- ### Calculate Spearman Correlation for Pathways Source: https://github.com/jackiehanlab/tosica/blob/main/reproducibility/Fig4.ipynb Computes Spearman correlation coefficients between cell stages and pathway expression indices for a specific cell type and cancer subset. ```python from scipy.stats import spearmanr, pearsonr sub = adata[adata.obs.Celltype=='Macro_LYVE1',:] sub = sub[sub.obs.cancer=='ESCA',:] rcc = pd.DataFrame(sub.var['pathway_index']) rcc['rcc'] = 0 rcc['p'] = 0 for i in range(len(rcc)): rr = spearmanr(sub.obs.Stage,sub.X[:,i]) rcc.loc[rcc.index[i],'rcc'] = rr[0] rcc.loc[rcc.index[i],'p'] = rr[1] rcc.sort_values(by='rcc', ascending=False) ``` -------------------------------- ### Trajectory Inference Source: https://github.com/jackiehanlab/tosica/blob/main/reproducibility/Fig4.ipynb Subsets the data and performs trajectory analysis using Diffusion Maps and DPT. ```python sub = adata[adata.obs.Prebigtype=='cDC',:] sub = sub[sub.obs.bigtype=='cDC',:] sub = sub[sub.obs.tissue=='T',:] sc.pp.scale(sub, max_value=10) sc.tl.pca(sub, svd_solver='arpack') sc.pp.neighbors(sub, n_neighbors=10, n_pcs=40) sc.tl.umap(sub) sc.pl.umap(sub, color='Precelltype') sc.tl.diffmap(sub) sub.uns['iroot'] = np.flatnonzero(sub.obs['Precelltype'] == 'cDC3_LAMP3')[5] sc.tl.dpt(sub) sc.pl.diffmap(sub, color='Precelltype') ``` -------------------------------- ### TOSICA.pre Source: https://github.com/jackiehanlab/tosica/blob/main/README.md Predicts cell types for a query dataset using a pre-trained TOSICA model. ```APIDOC ## TOSICA.pre ### Description Performs cell-type prediction on a query dataset using weights generated during the training phase. ### Parameters #### Request Body - **query_adata** (AnnData) - Required - An AnnData object of the query dataset. - **model_weight_path** (string) - Optional - Path to the model weights file (.pth). - **project** (string) - Required - Name of the project folder created during training. ### Response - **new_adata.X** (matrix) - Attention matrix. - **new_adata.obs['Prediction']** (list) - Predicted labels. - **new_adata.obs['Probability']** (list) - Probability of the prediction. - **new_adata.var['pathway_index']** (list) - Gene set of each column. ``` -------------------------------- ### Predict Cell Types with TOSICA Model Source: https://github.com/jackiehanlab/tosica/blob/main/README.md Predicts cell types for a query AnnData object using a trained TOSICA model. Optionally, specific model weights can be provided. ```python new_adata = TOSICA.pre(query_adata, model_weight_path = ,project=) ``` -------------------------------- ### Plot Violin Plot of Gene Expression Source: https://github.com/jackiehanlab/tosica/blob/main/reproducibility/Fig4.ipynb Generates a violin plot to visualize the expression of specified genes across different stages. Requires the 'scanpy' library and an AnnData object. ```python sc.pl.violin(sub, ['REACTOME_SIGNALING_BY_FGFR','REACTOME_INTERFERON_SIGNALING'], groupby='Stage',use_raw=True) ``` -------------------------------- ### Ensure Consistent Gene Order Source: https://github.com/jackiehanlab/tosica/blob/main/README.md Ensures that the gene (variable) names in the query AnnData object are consistent with and in the same order as the reference AnnData object before prediction. ```python query_adata = query_adata[:,ref_adata.var_names] ``` -------------------------------- ### Scatter Plot of Gene Expression Source: https://github.com/jackiehanlab/tosica/blob/main/reproducibility/Fig4.ipynb Generates a scatter plot to visualize the relationship between two genes, colored by cell type. Requires the 'scanpy' library and a pre-processed AnnData object. ```python sc.pl.scatter(sub,x='REACTOME_TOLL_RECEPTOR_CASCADES',y='REACTOME_NOD1_2_SIGNALING_PATHWAY',color='Precelltype',use_raw=True) ``` -------------------------------- ### Save AnnData Object Source: https://github.com/jackiehanlab/tosica/blob/main/reproducibility/Fig4.ipynb Saves the current state of the AnnData object to a .h5ad file. This is useful for preserving processed data for later analysis or sharing. ```python adata.write_h5ad('./Fig4.h5ad') ``` -------------------------------- ### Rank Genes Groups Source: https://github.com/jackiehanlab/tosica/blob/main/reproducibility/Fig4.ipynb Identifies marker genes for clusters using the Wilcoxon rank-sum test. ```python sc.tl.rank_genes_groups(sub, 'Precelltype', method='wilcoxon') dc_pathway = pd.DataFrame(sub.uns['rank_genes_groups']['names']) dc_pathway ``` -------------------------------- ### Assign Colors and Categories for Plotting Source: https://github.com/jackiehanlab/tosica/blob/main/test/tutorial.ipynb Assigns specific colors and reorders categories for 'Prediction' and 'Celltype' observation columns in the AnnData object to ensure consistent visualization. ```python col = np.array([ "#98DF8A","#E41A1C" ,"#377EB8", "#4DAF4A" ,"#984EA3" ,"#FF7F00" ,"#FFFF33" ,"#A65628" ,"#F781BF" ,"#999999","#1F77B4","#FF7F0E","#279E68","#FF9896" ]).astype('