<jupyter_start><jupyter_text>Create ScMags ObjectCreating the ScMags object is very simple.\Data matrix and labels are mandatory gene names are optional.* In the data matrix, rows must correspond to cells, columns must correspond to genes, and must be in one of three formats: `numpy.ndarry`, `scipy.sparse.csr_matrix`, or `scipy.sparse.csc_matrix`. * Labels and gene names should be in numpy.ndarray format An example for the pollen dataset\In any location in the folder named pollen the data matrix get the labels and gene names.<jupyter_code>%%bash 
ls Pollen<jupyter_output>Pollen_Data.csv
Pollen_Data_markers_res_ann.csv
Pollen_Data_markers_res_ind.csv
Pollen_Gene_Ann.csv
Pollen_Labels.csv<jupyter_text>Let's read the data and convert it to numpy.ndarray format<jupyter_code>import pandas as pd

pollen_data = pd.read_csv('Pollen/Pollen_Data.csv',sep=',', header = 0,  index_col = 0).to_numpy().T
pollen_labels = pd.read_csv('Pollen/Pollen_Labels.csv', sep=',', header = 0,  index_col = 0).to_numpy()
gene_names = pd.read_csv('Pollen/Pollen_Gene_Ann.csv', sep=',', header = 0,  index_col = 0).to_numpy()

pollen_labels = pollen_labels.reshape(pollen_data.shape[0])
gene_names = gene_names.reshape(pollen_data.shape[1])<jupyter_output><empty_output><jupyter_text>* Sizes of data labels and gene names must match. * In addition, labels and gene names must be a one-dimensional array.<jupyter_code>print(pollen_data.shape)
print(type(pollen_data))
print(pollen_labels.shape)
print(type(pollen_labels))
print(pollen_data.shape)
print(type(pollen_labels))<jupyter_output>(301, 23730)
<class 'numpy.ndarray'><jupyter_text>Now let's create the `ScMags` object<jupyter_code>import scmags as sm
pollen = sm.ScMags(data=pollen_data, labels=pollen_labels, gene_ann=gene_names)<jupyter_output><empty_output><jupyter_text>Then the desired operations can be performed.<jupyter_code>pollen.filter_genes()
pollen.sel_clust_marker()
pollen.get_markers()<jupyter_output>-> Eliminating low expression genes
-> Selecting cluster-specific candidate marker genes
-> Selecting  markers for each cluster<jupyter_text>* If gene names are not given, they are created from indexes inside.<jupyter_code>pollen = sm.ScMags(data=pollen_data, labels=pollen_labels)
pollen.filter_genes()
pollen.sel_clust_marker()
pollen.get_markers()<jupyter_output>-> Eliminating low expression genes
-> Selecting cluster-specific candidate marker genes
-> Selecting  markers for each cluster<jupyter_text>* These names are actually indices of genes in the data matrix.<jupyter_code>pollen.get_markers(ind_return=True)<jupyter_output><empty_output><jupyter_text>Data matrix can be in sparse matrix other than `numpy.ndarray` For example:<jupyter_code>from scipy import sparse
pollen_data = sparse.csr_matrix(pollen_data)
print(pollen_data.shape)
print(type(pollen_data))
pollen_data
pollen = sm.ScMags(data=pollen_data, labels=pollen_labels, gene_ann=gene_names)
pollen.filter_genes()
pollen.sel_clust_marker()
pollen.get_markers()<jupyter_output>-> Eliminating low expression genes
-> Selecting cluster-specific candidate marker genes
-> Selecting  markers for each cluster
{'fraction_non_alphanumeric': 0.09639323332269391, 'fraction_numerical': 0.005106926268751995, 'mean_word_length': 7.562841530054645, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '510686', 'license': 'Apache-2.0', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1063, 'n_words': 261, 'path': 'docs/source/cr_scmags.ipynb', 'repo_name': 'doganlab/scmags', 'size': '3133'}