La estructura de .mat en Python
Aquí descubrirás qué incluye MATLAB que has cargado en el ejercicio anterior.
El archivo 'albeck_gene_expression.mat' ya está cargado
en la variable mat. Las siguientes bibliotecas ya
se han importado de la siguiente manera:
import scipy.io
import matplotlib.pyplot as plt
import numpy as np
Una vez más, este archivo contiene datos de expresión génica del laboratorio de Albeck en la UCDavis.
Este ejercicio forma parte del curso
Introducción a la importación de datos en Python
Instrucciones del ejercicio
- Utiliza el método
.keys()en el diccionariomatpara imprimir las claves. La mayoría de estas claves (de hecho, las que empiezanNOT y terminan por «__») son variables del entorno MATLAB correspondiente. - Imprime el tipo del valor correspondiente a la clave
'CYratioCyt'enmat. Recuerda quemat['CYratioCyt']accede al valor. - Imprime la forma del valor correspondiente a la clave
'CYratioCyt'utilizando la funciónnumpyshape(). - ¡Ejecuta el script completo para ver algunos datos de expresión génica oscilatoria!
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# 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()