<jupyter_start><jupyter_text>PCA of ABA Spatial Transcriptomics<jupyter_code># importing libraries
import numpy as np
from sklearn.cluster import KMeans
from sklearn.decomposition import PCA
# Loading the preprocessed data into the pipeline
# The steps are explained in the '00_preprocessing' folder
# Summary: E(v,g) matrix is made, masked for brain, -1s changed to 0s, and standard scaled
# NOT INCLUDED in the files folder of this repo
X = np.load('preprocessed_data/mask_pos_std.npy')
# Running PCA

pca = PCA(n_components = n_components, random_state = 0)
components = pca.fit_transform(X)
weights = pca.components_
# Clustering the components

kmeans = KMeans(n_clusters = n_clusters, random_state = 0)
kmeans.fit_predict(components)
labels = kmeans.labels_<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07566204287515763, 'fraction_numerical': 0.007566204287515763, 'mean_word_length': 6.218181818181818, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '20645', 'license': 'MIT', 'n_tokens_mistral': 275, 'n_tokens_neox': 252, 'n_words': 82, 'path': 'Notebooks/01_dimension_reduction/ABA_PCA.ipynb', 'repo_name': 'BioProteanLabs/SFt_pipeline', 'size': '793'}