# Visualizing Proteomics Data

Read in data

```
ms=pd.read_csv("C:\\Users\duan\Desktop\IntroductionToSeaborn\mass_spec_new.csv")
```

```
ms
```

<figure><img src="/files/YbnjCVsB14HRNEC1yOYT" alt=""><figcaption></figcaption></figure>

```
a = sns.histplot(ms['light Precursor Mz'], bins=20) #simple, right?
```

<figure><img src="/files/HKnXIQnOMrfG9MXzeZE9" alt=""><figcaption></figcaption></figure>

```
a = sns.histplot(data=ms,x='light Precursor Mz', bins=20, kde="TRUE",color="lightseagreen",alpha=0.1)#make the plot more elegant
```

<figure><img src="/files/ToB0E90dOAu33jhTQxdJ" alt=""><figcaption></figcaption></figure>

```
a = sns.histplot(data=ms,x='light +1 charge mass', bins=20, kde="TRUE",color="red",alpha=0.1)  #O no, what could be wrong?
```

<figure><img src="/files/OBiETsfdikW5zlnQcRkm" alt=""><figcaption></figcaption></figure>

```
v = ms['light +1 charge mass'].values #get all of the values
v.sort() #sort the values
v #print the values - what's wrong?
```

![](/files/Rs4i8qrRB2VmA6lVaVuI) ![](/files/6N9aISGC0OgGI8NQirD6)

```
ms['light +1 charge mass']=ms['light Precursor Mz']*ms['Precursor Charge'] - ((ms['Precursor Charge']-1)*1.0078)
```

```
a = sns.histplot(data=ms,x='light +1 charge mass', bins=20, kde="TRUE",color="red",alpha=0.1)
```

<figure><img src="/files/qhpTd46MZ0jwkkpvrmgi" alt=""><figcaption></figcaption></figure>

```
#Let's see if +2 and +3 charged peptides exhibit a different distribution.
a = sns.histplot(data=ms.loc[ms['Precursor Charge'] == 3], x='light +1 charge mass', bins=10, label='+3',kde="TRUE",color="chocolate",alpha=0.2)
sns.histplot(data=ms.loc[ms['Precursor Charge'] == 2], x='light +1 charge mass', bins=10, ax=a, label='+2',kde="TRUE",color="orchid",alpha=0.1)
a.legend()
```

<figure><img src="/files/6ySBtO44tDjWWqUeSBHO" alt=""><figcaption></figcaption></figure>

```
#Here, I made a new column that is the ratio of light-to-heavy intensity...the details aren't important. What is important is that we have a new column of values we can plot
ms['Total Area Ratio BT2_HFX_5'] = ms['light BT2_HFX_5 Total Area']/ms['15N BT2_HFX_5 Total Area']
ms['Total Area Ratio BT2_HFX_7'] = ms['light BT2_HFX_7 Total Area']/ms['15N BT2_HFX_7 Total Area']
```

```
sns.set_context('poster') #you don't need to do this - it's just to make the figures easier to see
f = pylab.figure(figsize=(20,10))
swarm = sns.swarmplot(x='Protein Gene', y='Total Area Ratio BT2_HFX_5', data=ms.loc[0:100,:], size=6)
pylab.tight_layout()
pylab.savefig('swarmplot.png')
```

<figure><img src="/files/lCjmN15KXEeS4WHUCfHt" alt=""><figcaption></figcaption></figure>

```
sns.set_context('poster') #you don't need to do this - it's just to make the figures easier to see
f = pylab.figure(figsize=(20,10))
box = sns.boxplot(x='Protein Gene', y='Total Area Ratio BT2_HFX_5', data=ms.loc[0:100,:])
pylab.tight_layout()
pylab.savefig('boxplot.pdf') #this will save your figure!
```

<figure><img src="/files/kuAPxO5l2l7ZZwIN6Pv6" alt=""><figcaption></figcaption></figure>

```
sns.set_context('poster') #you don't need to do this - it's just to make the figures easier to see
f = pylab.figure(figsize=(20,10))
box = sns.violinplot(x='Protein Gene', y='Total Area Ratio BT2_HFX_5', data=ms.loc[0:30,:])
#pylab.tight_layout()
pylab.savefig('boxplot.pdf') #this will save your figure!
```

<figure><img src="/files/JU3540Pb0KmvYQSDXine" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://igb.mit.edu/mini-courses/python/data-processing-with-python/seaborn/visualizing-proteomics-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
