.mat의 구조를 Python에서 살펴보기
이제 이전 연습 문제에서 불러온 MATLAB 사전에 무엇이 들어 있는지 살펴보겠습니다.
파일 'albeck_gene_expression.mat'은 이미 변수 mat에
로드되어 있어요. 또한 다음과 같이 라이브러리가
이미 임포트되어 있습니다:
import scipy.io
import matplotlib.pyplot as plt
import numpy as np
이 파일에는 UCDavis의 Albeck Lab에서 수집한 유전자 발현 데이터가 들어 있습니다.
이 연습은 강의의 일부입니다
Python에서 데이터 가져오기 입문
연습 안내
- 사전
mat에 대해.keys()메서드를 사용해 키를 출력하세요. 대부분의 키(앞뒤가 '__'로 시작하고 끝나지 않는 것들)는 해당 MATLAB 환경의 변수입니다. mat에서 키'CYratioCyt'에 해당하는 값의 타입을 출력하세요.mat['CYratioCyt']로 값을 접근합니다.numpy의shape()함수를 사용해 키'CYratioCyt'에 해당하는 값의 모양(shape)을 출력하세요.- 스크립트 전체를 실행해 진동하는 유전자 발현 데이터를 확인해 보세요!
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# 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()