This is my first jupyter notebook

In [2]:
import matplotlib.pyplot as plt
import numpy as np
In [6]:
x = np.linspace (0,2,100)
fig, ax = plt.subplots()
#ax.plot (x,x**2)
ax.plot (x, 2*x)
ax.set_xlabel("x axis")
ax.set_ylabel("y axis")
plt.show()
No description has been provided for this image
In [15]:
#calculate costs of sequencing 245Mbp at 2001 price, $10,000 per 1Mbp
#cost=10000.00
cost=0.001
bp1=248 #Mbpsfor chromosome 1
bp2=242
total_cost = cost*bp1 + cost*bp2
print(total_cost)
0.49
In [12]:
total_cost
Out[12]:
4900000.0
In [18]:
import pandas as pd

#read the excel file
data = pd.read_excel("CHrompose.xltx") #for .xls make sure 'xlrd' is installed
In [19]:
data
Out[19]:
chrmoosomes baspepiars
0 1 248956422
1 2 242193529
2 3 198295559
3 4 190214555
4 5 181538259
5 6 170805979
6 7 159345973
7 8 145138636
8 9 138394717
9 10 133797422
10 11 135086622
11 12 133275309
12 13 114364328
13 14 107043718
14 15 101991189
15 16 90338345
16 17 83257441
17 18 80373285
18 19 58617616
19 20 64444167
20 21 46709983
21 22 50818468
22 X 156040895
23 Y 57227415
In [23]:
cost_2021 = 10000.0
cost_2011 = 0.10
cost_2021 = 0.01
In [25]:
#df['Sequencing_Cost'] = df['Length_Mbps'] * 10000
data['sequencing_cost_2001']=data['baspepiars']*cost_2021/1000000
In [26]:
data
Out[26]:
chrmoosomes baspepiars sequencing_cost_2001
0 1 248956422 2.489564
1 2 242193529 2.421935
2 3 198295559 1.982956
3 4 190214555 1.902146
4 5 181538259 1.815383
5 6 170805979 1.708060
6 7 159345973 1.593460
7 8 145138636 1.451386
8 9 138394717 1.383947
9 10 133797422 1.337974
10 11 135086622 1.350866
11 12 133275309 1.332753
12 13 114364328 1.143643
13 14 107043718 1.070437
14 15 101991189 1.019912
15 16 90338345 0.903383
16 17 83257441 0.832574
17 18 80373285 0.803733
18 19 58617616 0.586176
19 20 64444167 0.644442
20 21 46709983 0.467100
21 22 50818468 0.508185
22 X 156040895 1.560409
23 Y 57227415 0.572274
In [ ]:
 
In [27]:
total_cost_2001=data['sequencing_cost_2001'].sum()
In [28]:
print(total_cost_2001)
30.882698320000003
In [31]:
total_cost_2011=data['sequencing_cost_2011'].sum()
print(total_cost_2011)
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
File /opt/anaconda3/lib/python3.12/site-packages/pandas/core/indexes/base.py:3805, in Index.get_loc(self, key)
   3804 try:
-> 3805     return self._engine.get_loc(casted_key)
   3806 except KeyError as err:

File index.pyx:167, in pandas._libs.index.IndexEngine.get_loc()

File index.pyx:196, in pandas._libs.index.IndexEngine.get_loc()

File pandas/_libs/hashtable_class_helper.pxi:7081, in pandas._libs.hashtable.PyObjectHashTable.get_item()

File pandas/_libs/hashtable_class_helper.pxi:7089, in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'sequencing_cost_2011'

The above exception was the direct cause of the following exception:

KeyError                                  Traceback (most recent call last)
Cell In[31], line 1
----> 1 total_cost_2011=data['sequencing_cost_2011'].sum()
      2 print(total_cost_2011)

File /opt/anaconda3/lib/python3.12/site-packages/pandas/core/frame.py:4102, in DataFrame.__getitem__(self, key)
   4100 if self.columns.nlevels > 1:
   4101     return self._getitem_multilevel(key)
-> 4102 indexer = self.columns.get_loc(key)
   4103 if is_integer(indexer):
   4104     indexer = [indexer]

File /opt/anaconda3/lib/python3.12/site-packages/pandas/core/indexes/base.py:3812, in Index.get_loc(self, key)
   3807     if isinstance(casted_key, slice) or (
   3808         isinstance(casted_key, abc.Iterable)
   3809         and any(isinstance(x, slice) for x in casted_key)
   3810     ):
   3811         raise InvalidIndexError(key)
-> 3812     raise KeyError(key) from err
   3813 except TypeError:
   3814     # If we have a listlike key, _check_indexing_error will raise
   3815     #  InvalidIndexError. Otherwise we fall through and re-raise
   3816     #  the TypeError.
   3817     self._check_indexing_error(key)

KeyError: 'sequencing_cost_2011'
In [ ]: