The structure of .mat in Python
Here, you'll discover what is in the MATLAB dictionary that you loaded in the previous exercise.
The file 'albeck_gene_expression.mat'
is already loaded
into the variable mat
. The following libraries have already
been imported as follows:
import scipy.io
import matplotlib.pyplot as plt
import numpy as np
Once again, this file contains gene expression data from the Albeck Lab at UCDavis.
This exercise is part of the course
Introduction to Importing Data in Python
Exercise instructions
- Use the method
.keys()
on the dictionarymat
to print the keys. Most of these keys (in fact the ones that do NOT begin and end with '__') are variables from the corresponding MATLAB environment. - Print the type of the value corresponding to the key
'CYratioCyt'
inmat
. Recall thatmat['CYratioCyt']
accesses the value. - Print the shape of the value corresponding to the key
'CYratioCyt'
using thenumpy
functionshape()
. - Execute the entire script to see some oscillatory gene expression data!
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Print the keys of the MATLAB dictionary
print(____)
# Print the type of the value corresponding to the key 'CYratioCyt'
# Print the shape of the value corresponding to the key 'CYratioCyt'
# Subset the array and plot it
data = mat['CYratioCyt'][25, 5:]
fig = plt.figure()
plt.plot(data)
plt.xlabel('time (min.)')
plt.ylabel('normalized fluorescence (measure of expression)')
plt.show()