<jupyter_start><jupyter_text>Exploratory Data Analysis Author: <NAME><jupyter_code># Load Libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline<jupyter_output><empty_output><jupyter_text>||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Dataset 1: Human dataset |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||<jupyter_code># Load datasets
human = pd.read_table('../datasets/human.txt',)
human.head()<jupyter_output><empty_output><jupyter_text>Check number of observations/DNA Sequences and the data type<jupyter_code>print(f'The length of the human DNA squence is {human.shape[0]} and it consists of {human.shape[1]} columns.')
human.dtypes<jupyter_output><empty_output><jupyter_text>Check if there is null or NAN data<jupyter_code>human.isnull().sum()<jupyter_output><empty_output><jupyter_text>Count the number of characters in each sequance<jupyter_code># create a new column "sequence_length" to save the number of sequence length or 
# number of nucleobases (i.e., A, T, G, C) in each class (or gene family)

human['sequence_length'] = human['sequence'].str.len()
plt.figure(figsize = (12,4))
plt.title('Human DNA squence dataset', fontsize = 16)
plt.barh(human['class'], human['sequence_length'])
plt.xlabel('Nucleotide Count', fontsize = 12)
plt.ylabel('Gene family Class', fontsize = 12)
plt.xticks(fontsize=12)
plt.yticks(fontsize=12);
fig, ax = plt.subplots(figsize=(12, 6))
plt.title('Human DNA squence dataset', fontsize = 16)
sns.barplot(x='class', y='sequence_length', data= human)
plt.ylabel('Nucleotide Count', fontsize = 12)
plt.xlabel('Gene family Class', fontsize = 12)
plt.xticks(fontsize=12)
plt.yticks(fontsize=12);<jupyter_output><empty_output><jupyter_text>Count the number of A, T, G, and C nucleotide in each sequence and each class<jupyter_code># in the original post
human['A_count'] = [seq.count('A') for seq in human['sequence']]
human['T_count'] = [seq.count('T') for seq in human['sequence']]
human['G_count'] = [seq.count('G') for seq in human['sequence']]
human['C_count'] = [seq.count('C') for seq in human['sequence']]
human
human.groupby(by=['class']).sum()
plt.figure(figsize=(12, 6))
human.groupby(by=['class']).sum().drop(columns=['sequence_length']).plot(kind='barh', figsize=(12, 6));
plt.title('Number of A, T, G, and C in human DNA dataset', fontsize = 16)
plt.xlabel('Nucleotide Count', fontsize = 12)
plt.ylabel('Gene family Class', fontsize = 12)
plt.legend(fontsize=12)
plt.xticks(fontsize=12)
plt.yticks(fontsize=12);
human.to_csv('../outputs/processed_human_sequence.csv', header=human.columns, index_label=False)<jupyter_output><empty_output><jupyter_text>---  ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Dataset 2: Chimpanzee dataset |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||<jupyter_code># Load datasets
chimpanzee = pd.read_table('../datasets/chimpanzee.txt')
chimpanzee<jupyter_output><empty_output><jupyter_text>check number of observations/DNA Sequences<jupyter_code>chimpanzee.shape
chimpanzee.dtypes<jupyter_output><empty_output><jupyter_text>check/drop Null data<jupyter_code>chimpanzee.isnull().sum()<jupyter_output><empty_output><jupyter_text>count the number of characters in each Chimpanzee Seqeunce<jupyter_code>chimpanzee['sequence_length'] = chimpanzee['sequence'].str.len()
plt.figure(figsize = (12,4))
plt.title('Chimpanzee DNA sequence dataset', fontsize = 16)
plt.barh(chimpanzee['class'], chimpanzee['sequence_length'])
plt.xlabel('Nucleotide Count', fontsize = 12)
plt.ylabel('Gene family Class', fontsize = 12)
plt.xticks(fontsize=12)
plt.yticks(fontsize=12);
fig, ax = plt.subplots(figsize=(12, 6))
plt.title('Chimpanzee DNA sequence dataset', fontsize = 16)
sns.barplot(x='class', y='sequence_length', data= chimpanzee)
plt.ylabel('Nucleotide Count', fontsize = 12)
plt.xlabel('Gene family Class', fontsize = 12)
plt.xticks(fontsize=12)
plt.yticks(fontsize=12);<jupyter_output><empty_output><jupyter_text>Count the number of A, T, G, and C nucleotide in each sequence and each class<jupyter_code># in the original post
chimpanzee['A_count'] = [seq.count('A') for seq in chimpanzee['sequence']]
chimpanzee['T_count'] = [seq.count('T') for seq in chimpanzee['sequence']]
chimpanzee['G_count'] = [seq.count('G') for seq in chimpanzee['sequence']]
chimpanzee['C_count'] = [seq.count('C') for seq in chimpanzee['sequence']]
chimpanzee.head()
chimpanzee.groupby(by=['class']).sum()
plt.figure(figsize=(12, 6))
chimpanzee.groupby(by=['class']).sum().drop(columns=['sequence_length']).plot(kind='barh', figsize=(12, 6));
plt.title('Number of A, T, G, and C in human DNA dataset', fontsize = 16)
plt.xlabel('Nucleotide Count', fontsize = 12)
plt.ylabel('Gene Family Class', fontsize = 12)
plt.legend(fontsize=12)
plt.xticks(fontsize=12)
plt.yticks(fontsize=12);
chimpanzee.to_csv('../outputs/processed_chimpanzee_sequence.csv', header=chimpanzee.columns, index_label=False)<jupyter_output><empty_output><jupyter_text>||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Dataset 3: Dog dataset |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||<jupyter_code># Load datasets
dog = pd.read_table('../datasets/dog.txt')
dog<jupyter_output><empty_output><jupyter_text>check number of observations/DNA Sequences<jupyter_code>dog.shape
dog.dtypes<jupyter_output><empty_output><jupyter_text>count the number of characters in each Chimpanzee Seqeunce<jupyter_code>dog['sequence_length'] = dog['sequence'].str.len()
plt.figure(figsize = (12,4))
plt.title('Dog DNA sequence dataset', fontsize = 16)
plt.barh(dog['class'], dog['sequence_length'])
plt.xlabel('Nucleotide Count', fontsize = 12)
plt.ylabel('DNA Gene Family Class', fontsize = 12)
plt.xticks(fontsize=12)
plt.yticks(fontsize=12);
fig, ax = plt.subplots(figsize=(12, 6))
plt.title('Dog DNA sequence dataset', fontsize = 16)
sns.barplot(x='class', y='sequence_length', data= dog)
plt.ylabel('Nucleotide Count', fontsize = 12)
plt.xlabel('DNA Gene Family Class', fontsize = 12)
plt.xticks(fontsize=12)
plt.yticks(fontsize=12);<jupyter_output><empty_output><jupyter_text>Count the number of A, T, G, and C nucleotide in each sequence and each class<jupyter_code># in the original post
dog['A_count'] = [seq.count('A') for seq in dog['sequence']]
dog['T_count'] = [seq.count('T') for seq in dog['sequence']]
dog['G_count'] = [seq.count('G') for seq in dog['sequence']]
dog['C_count'] = [seq.count('C') for seq in dog['sequence']]
dog.head()
dog.groupby(by=['class']).sum()
plt.figure(figsize=(12, 6))
dog.groupby(by=['class']).sum().drop(columns=['sequence_length']).plot(kind='barh', figsize=(12, 6));
plt.title('Number of A, T, G, and C in dog DNA dataset', fontsize = 16)
plt.xlabel('Nucleotide Count', fontsize = 12)
plt.ylabel('DNA gene family Class', fontsize = 12)
plt.legend(fontsize=12)
plt.xticks(fontsize=12)
plt.yticks(fontsize=12);
dog.to_csv('../outputs/processed_dog_sequence.csv', header=dog.columns, index_label=False)
# pd.read_csv('../outputs/processed_dog_sequence.csv')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2602127939051622, 'fraction_numerical': 0.01799553395507684, 'mean_word_length': 9.111553784860558, 'pattern_counts': {'":': 0, '<': 62, '<?xml version=': 0, '>': 62, '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': '15', 'dir': 'jupyter-structured-clean-dedup', 'id': '652362', 'license': 'MIT', 'n_tokens_mistral': 3101, 'n_tokens_neox': 2882, 'n_words': 527, 'path': 'notebooks/1__Exploratory_Data_Analysis_EDA.ipynb', 'repo_name': 'EhsanGharibNezhad/DNA_Sequencing_Using_Machine_Learning_Algorithms', 'size': '7626'}