Machine learning predictions from unpredictable chaos
收藏资源简介:
Code Description The code has five parts, including B-factor prediction, EEG data, image classification, RS Plot, and SingleCellDataProcess. Each part has several routines wrote by Python. Please make sure to modify the file paths in the routines to the reader's own paths, and install the Python packages mentioned at the beginning of the routine. Readers can remove the numbers at the beginning of the code when running the program. The details of main purpose of all routines are as following: B-factor prediction(1) PDB_data_process.py: Loads the three-dimensional coordinates and B-factors for each protein.(2) plot_B_prediction.py: Plots the 3D structure of a specific protein, colored by both experimental B-factors and predicted B-factors from different methods.(3) slurm_364_B_3_1.py + multi_slurm_364.py: The first code simulates synchronization behavior in a system based on the Lorenz model, updating the state (x, y, z) of atoms by solving dynamic equations, calculating the synchronization index, and analyzing the relationship between the protein's B-factor and the simulation results using a multiple linear regression model. The second code, when updated with the pdbID, can traverse 364 protein datasets and generate job scripts for submission on a Slurm-managed high-performance computing cluster, enabling large-scale simulations and distributed computing analysis. EEG data(1) cang_lorenz.py: Feature extraction from EEG data using Lorenz system.(2) cang_rossler.py: Feature extraction from EEG data using Rossler system.(3) KNN.py: Classification prediction by features using machine learning algorithms.(4) LSTM.py: Using LSTM model for classification prediction from time series.(5) RNN.py: Using RNN model for classification prediction from time series. image classification(1) allaml_classification_pca.py: use PCA method to do the classification prediction of image data.(2) allaml_classification_tsne.py: use t-SNE method to do the classification prediction of image data.(3) allaml_classification_umap.py: use Umap method to do the classification prediction of image data.(4) win_Lorentz_allaml_feature.py: use Lorentz oscillators to generate the features of image data.(5) win_rossler_allaml_feature.py: use Rossler oscillators to generate the features of image data.(6) win_allaml_feature_CHEN.py: use Chen oscillators to generate the features of image data. RS Plot(1) rs_plot.py:implement the residue-similarity (R-S) analysis for the clustering visualization of classification performance on single cell RNA sequencing (scRNA-seq) data sets.(2) rs_score.py: calculate the residue score and the similarity score, which are introduced to evaluate and visualize dimensionality reduction, clustering, and classification algorithms.(3) rs_Umap_heatmap_plot.py: R-S plot, Umap, and confusion marix of RS plots of scRNA-seq data sets.(4) u-map.py: Umap plots for scRNA-seq data sets. SingleCellDataProcess(1) classification_DBZ_GBDT.py: classification prediction for single cell RNA sequencing with GradientBoostingClassifier and five-fold cross validation.(2) classification_DBZ_RF.py: classification prediction for single cell RNA sequencing with RandomForestClassifier and five-fold cross validation.(3) classification_DBZ_SVM.py: classification prediction for single cell RNA sequencing with svm algorithm and five-fold cross validation.(4) slurm_GSE_feature_4_runge.py: generate features with four-order Runge Kuta algorithm for single cell RNA sequencing data.(5) slurm_GSE_feature.py: generate features with one-order forward Euler algorithm for single cell RNA sequencing data. Data Description EEG data of the normal category, preictal category, and seizure categoryAnother EEG datasets used in Fig.3a of main text is the publicly available EEG dataset collected and curated by Andrzejak et al. from the University of Bonn, Germany. This dataset can be accessed from the official website of the Epileptology Department at the University of Bonn. The normal category (o.zip) comprises single-channel EEG segments recorded from healthy individuals with no history of epilepsy. The preictal category (f.zip) consists of EEG signals collected from epilepsy patients during non-seizure periods. Meanwhile, the seizure category (s.zip) includes EEG signals recorded from the same patients during epileptic seizures. SET B corresponds to o.zip, SET D corresponds to f.zip, and SET E corresponds to s.zip. Each category contains 100 single-channel EEG signals, with each signal having a duration of 23.6 seconds. The sampling frequency of the recordings is 173.61 Hz, resulting in a total of 4097 data points per signal. ImageThe Columbia Object Image Library (COIL-20) is a well-known image dataset created for machine learning and computer vision research, especially in object classification. Compiled at Columbia University in 1996, it contains images of 20 different objects, each photographed from various angles. Specifically, each object is captured at 5-degree intervals as it rotates a full 360 degrees, resulting in 72 images per object and a total of 1,440 images. The dataset includes a variety of everyday items like toys, household goods, and tools, which offer a wide range of shapes, textures, and colors. This diversity makes COIL-20 highly useful for developing and testing algorithms that need to generalize across different types of objects and their appearances. ProteinB-factor describes how much an atom fluctuate around its mean position in crystal structures. Protein B-factors quantitatively measure the relative thermal motion of each atom and reflects atomic flexibility and dynamics. Though B-factor is also affected by factors such as the refinement methods, it is still a relatively robust measurement of atomic flexibility in proteins. Single Cell RNA SequencingSingle cell RNA sequencing (scRNA-seq) reveals heterogeneity within cell types, leading to an understanding of cell−cell communication, cell differentiation, and differential gene expression. With current technology and protocols, more than 20,000 genes can be identified. Numerous data analysis pipelines have been developed to help analyze such complex data. Demonstration Figure 2In this section, the code and files we used are all stored in figures/Figure 2. (1)We obtained Figure 2a by running the persistent_homology_visualizer.py. Each of the sixteen nodes in the regular hexadecagon is injected with a Lorentz oscillator. The coupling or connectivity between these nodes is provided by the radius filtration of the persistent Laplace operator. The three plots display three typical filtration patterns. (2) Figures 2e-g show the visualizations of atom_coordinates_1.txt, atom_coordinates_2.txt, and atom_coordinates_3.txt, respectively. The point cloud images were created using PowerPoint, while the dynamic plots were generated by running the MND_filtration_eeg_cat018.py script. Panel e: Folding geometry and synchronized dynamics of a 120-element point cloud. Panel f: Partial folding geometry and partial synchronized dynamics of a 120-element point cloud. Panel g: Unfolded geometry and chaotic dynamics of a 120-element point cloud. Figure 4In this section, the code and files we used are all stored in figures/Figure 4. We saved the three-dimensional coordinates of the data points in topologicaldynamics.xyz and obtained Figures 4d-e by running the rips.py script. Panel d illustrates the filtration process of the point cloud, generating a sequence of simplicial complexes. Panel e shows the variation of the persistent Betti numbers as the filtration radius increases.
代码说明 本代码包含五个模块,分别为B因子预测(B-factor prediction)、脑电图(Electroencephalogram, EEG)数据处理、图像分类、RS绘图(RS Plot)以及单细胞数据处理(SingleCellDataProcess),每个模块均包含若干Python编写的程序脚本。请务必将脚本中的文件路径修改为使用者自身的本地路径,并安装脚本开头提及的Python依赖包。使用者运行程序时可移除代码开头的数字前缀。各脚本的主要用途如下: B因子预测模块 (1)PDB_data_process.py:加载每种蛋白质的三维坐标与B因子(B-factor)。 (2)plot_B_prediction.py:绘制特定蛋白质的三维结构,分别以实验测得的B因子与不同方法预测得到的B因子进行着色。 (3)slurm_364_B_3_1.py与multi_slurm_364.py:前者基于洛伦兹模型(Lorenz model)模拟系统的同步行为,通过求解动力学方程更新原子的状态(x, y, z),计算同步指数,并通过多元线性回归模型分析蛋白质B因子与模拟结果之间的关联;后者在输入pdbID后,可遍历364个蛋白质数据集,并生成可在Slurm管理的高性能计算集群上提交的作业脚本,以实现大规模模拟与分布式计算分析。 脑电图数据模块 (1)cang_lorenz.py:基于洛伦兹系统从脑电图数据中提取特征。 (2)cang_rossler.py:基于罗斯勒系统从脑电图数据中提取特征。 (3)KNN.py:采用机器学习算法基于特征进行分类预测。 (4)LSTM.py:采用长短期记忆网络(Long Short-Term Memory, LSTM)模型对时序数据进行分类预测。 (5)RNN.py:采用循环神经网络(Recurrent Neural Network, RNN)模型对时序数据进行分类预测。 图像分类模块 (1)allaml_classification_pca.py:采用主成分分析(Principal Component Analysis, PCA)方法对图像数据进行分类预测。 (2)allaml_classification_tsne.py:采用t分布邻域嵌入(t-distributed Stochastic Neighbor Embedding, t-SNE)方法对图像数据进行分类预测。 (3)allaml_classification_umap.py:采用均匀流形近似与投影(Uniform Manifold Approximation and Projection, UMAP)方法对图像数据进行分类预测。 (4)win_Lorentz_allaml_feature.py:采用洛伦兹振子生成图像数据的特征。 (5)win_rossler_allaml_feature.py:采用罗斯勒振子生成图像数据的特征。 (6)win_allaml_feature_CHEN.py:采用陈振子生成图像数据的特征。 RS绘图模块 (1)rs_plot.py:实现残差-相似性(residue-similarity, R-S)分析,用于单细胞RNA测序(single cell RNA sequencing, scRNA-seq)数据集分类性能的聚类可视化。 (2)rs_score.py:计算残差得分与相似性得分,用于评估与可视化降维、聚类及分类算法。 (3)rs_Umap_heatmap_plot.py:绘制单细胞RNA测序数据集的RS绘图、UMAP图与RS绘图混淆矩阵。 (4)u-map.py:绘制单细胞RNA测序数据集的UMAP图。 单细胞数据处理模块 (1)classification_DBZ_GBDT.py:采用梯度提升分类器(GradientBoostingClassifier)与五折交叉验证对单细胞RNA测序数据进行分类预测。 (2)classification_DBZ_RF.py:采用随机森林分类器(RandomForestClassifier)与五折交叉验证对单细胞RNA测序数据进行分类预测。 (3)classification_DBZ_SVM.py:采用支持向量机(Support Vector Machine, SVM)算法与五折交叉验证对单细胞RNA测序数据进行分类预测。 (4)slurm_GSE_feature_4_runge.py:采用四阶龙格-库塔算法为单细胞RNA测序数据生成特征。 (5)slurm_GSE_feature.py:采用一阶前向欧拉算法为单细胞RNA测序数据生成特征。 数据说明 脑电图数据:包含正常组、发作前组与发作期组三类数据 正文图3a使用的另一组脑电图数据集为德国波恩大学Andrzejak等人收集并整理的公开脑电图数据集,可通过波恩大学癫痫学系官方网站获取。其中正常组("o.zip")包含来自无癫痫病史健康个体的单通道脑电片段;发作前组("f.zip")包含癫痫患者非发作期采集的脑电信号;发作期组("s.zip")包含同一批患者癫痫发作期间采集的脑电信号。该数据集的SET B对应"o.zip"、SET D对应"f.zip"、SET E对应"s.zip"。每类数据包含100条单通道脑电信号,每条信号时长为23.6秒,采样频率为173.61 Hz,每条信号共包含4097个数据点。 图像数据集 哥伦比亚大学对象图像库(Columbia Object Image Library, COIL-20)是为机器学习与计算机视觉研究,尤其是对象分类任务构建的经典图像数据集。该数据集于1996年由哥伦比亚大学整理完成,包含20种不同对象的图像,每种对象以5度为间隔拍摄完整360度旋转过程中的图像,因此每个对象对应72张图像,数据集总共有1440张图像。数据集涵盖玩具、家居用品与工具等多种日常物品,包含丰富的形状、纹理与色彩多样性,这一特性使其非常适用于开发与测试需要在不同对象及其外观间泛化的算法。 蛋白质B因子 B因子用于描述晶体结构中原子围绕其平均位置的波动幅度,可定量表征每个原子的相对热运动,反映原子的柔性与动力学特性。尽管B因子也受精修方法等因素影响,但仍是衡量蛋白质原子柔性的相对可靠指标。 单细胞RNA测序 单细胞RNA测序(single cell RNA sequencing, scRNA-seq)可揭示细胞类型内的异质性,帮助理解细胞间通讯、细胞分化与差异基因表达。借助当前的技术与实验方案,单次测序可识别超过20000个基因,目前已开发出大量数据分析流程以辅助处理这类复杂数据集。 示例演示 图2 本部分使用的代码与文件均存储于figures/Figure 2目录下。 (1)运行persistent_homology_visualizer.py可得到图2a:正十六边形的16个节点均接入洛伦兹振子,节点间的耦合或连通性由持久拉普拉斯算子的半径过滤提供,三张子图展示了三种典型的过滤模式。 (2)图2e、2f与2g分别为atom_coordinates_1.txt、atom_coordinates_2.txt与atom_coordinates_3.txt的可视化结果。点云图像使用PowerPoint制作,动态图则通过运行MND_filtration_eeg_cat018.py脚本生成。子图e:包含120个元素的点云的折叠几何结构与同步动力学行为;子图f:包含120个元素的点云的部分折叠几何结构与部分同步动力学行为;子图g:包含120个元素的点云的展开几何结构与混沌动力学行为。 图4 本部分使用的代码与文件均存储于figures/Figure 4目录下。我们将数据点的三维坐标存储于topologicaldynamics.xyz文件中,运行rips.py脚本可得到图4d与4e。子图d展示了点云的过滤过程,生成一系列单纯复形(simplicial complex);子图e展示了随着过滤半径增加,持久贝蒂数(persistent Betti numbers)的变化情况。



