# import pandas as pd # train_file = '/home/bingxing2/ailab/group/ai4bio/public/multi-omics/multi-omics/downstream/EnhancerPromoter/train.csv' # val_file = '/home/bingxing2/ailab/group/ai4bio/public/multi-omics/multi-omics/downstream/EnhancerPromoter/val.csv' # test_file = '/home/bingxing2/ailab/group/ai4bio/public/multi-omics/multi-omics/downstream/EnhancerPromoter/test.csv' # # File paths # file_paths = [train_file, val_file, test_file] # def calculate_combined_statistics(file_paths, column_name): # """ Calculate max and mean lengths of the specified column across multiple CSV files """ # combined_df = pd.concat([pd.read_csv(file_path) for file_path in file_paths], ignore_index=True) # # Drop rows with NaN values in the specified column # combined_df = combined_df[combined_df[column_name].notna()] # # Compute lengths of the sequences # lengths = combined_df[column_name].apply(len) # return lengths.max(), lengths.mean() # # Calculate statistics for siRNA_sense_seq # print("enhancer statistics:") # max_len, mean_len = calculate_combined_statistics(file_paths, 'enhancer') # print(f"Max length = {max_len}, Mean length = {mean_len:.2f}") # # Calculate statistics for gene_target_seq # print("\npromoter statistics:") # max_len, mean_len = calculate_combined_statistics(file_paths, 'promoter') # print(f"Max length = {max_len}, Mean length = {mean_len:.2f}") # import matplotlib.pyplot as plt # def calculate_lengths(file_paths, column_name): # """ Calculate lengths of the specified column across multiple CSV files """ # lengths = [] # for file_path in file_paths: # df = pd.read_csv(file_path) # # Drop rows with NaN values in the specified column # df = df[df[column_name].notna()] # # Compute lengths of the sequences # lengths.extend(df[column_name].apply(len)) # return lengths # # File paths # # Calculate lengths for siRNA_sense_seq and gene_target_seq # siRNA_lengths = calculate_lengths(file_paths, 'enhancer') # gene_target_lengths = calculate_lengths(file_paths, 'promoter') # # Create histograms # plt.figure(figsize=(14, 7)) # # Plot for siRNA_sense_seq lengths # plt.subplot(1, 2, 1) # plt.hist(siRNA_lengths, bins=30, color='skyblue', edgecolor='black') # plt.title('enhancer Length Distribution') # plt.xlabel('Length') # plt.ylabel('Frequency') # # Plot for gene_target_seq lengths # plt.subplot(1, 2, 2) # plt.hist(gene_target_lengths, bins=30, color='lightgreen', edgecolor='black') # plt.title('promoter Length Distribution') # plt.xlabel('Length') # plt.ylabel('Frequency') # # Save the figure # plt.tight_layout() # plt.savefig('length_distributions.png') import pandas as pd # 定义 CSV 文件路径 csv_files = ['train.csv', 'val.csv', 'test.csv'] # 初始化统计字典 label_stats = {'train': {0: 0, 1: 0}, 'val': {0: 0, 1: 0}, 'test': {0: 0, 1: 0}} # 统计每个文件中的 label 数量 for file in csv_files: # 读取 CSV 文件 df = pd.read_csv(file) # 提取文件名(去掉 .csv 后缀) file_name = file.split('.')[0] # 统计 label 列中的 0 和 1 的数量 label_counts = df['label'].value_counts() # 更新统计字典 for label in label_counts.index: label_stats[file_name][label] = label_counts[label] # 打印统计结果 for dataset, counts in label_stats.items(): print(f"{dataset}.csv") print(f"Label 0: {counts[0]}") print(f"Label 1: {counts[1]}") print()