Table of Contents
"생물정보 후반 분석을 위한 주피터 활용" 교육 자료 모음 #
Jupyter & pandas #
참고정보
예제 데이터
- 인코고등학교 성적: 성적표.xlsx --> http://nbviewer.jupyter.org/gist/yong27/715c0ef9a09dd6eb37e9
- 대출현황: loan.csv
- 미국신생아 이름 분석: names.tgz --> http://nbviewer.jupyter.org/gist/yong27/966bd7c60a232add08c953e8519a95f1
- Allelic Differences Account for Gene Expression Differences Among Population: GSE5859, ethnicity.csv --> http://nbviewer.jupyter.org/gist/yong27/394cc70617977ee162993a78718f1eca
Matplotlib #
Matplolib 한글폰트 설정 #
윈도우에서
from matplotlib import font_manager, rc
font_name = font_manager.FontProperties(fname="c:/Windows/Fonts/malgun.ttf").get_name()
rc('font', family=font_name)
맥에서
matplotlib.font_manager.get_fontconfig_fonts()
krfont = {'family': 'AppleGothic', 'weight': 'bold', 'size': 10}
matplotlib.rc('font', **krfont)
리눅스에서
matplotlib.font_manager.get_fontconfig_fonts()
krfont = {'family': 'UnDotum', 'weight': 'bold', 'size': 10}
matplotlib.rc('font', **krfont)
실습 #
예제 데이터 다운로드 한 후, DataFrame으로 읽어오기
#!python
import pandas as pd
data = pd.read_csv('weight.csv')
연습문제 1 국가별 샘플 수 bar plot으로 그리기 (figsize: 10x10)
#!python
import matplotlib.pyplot as plt
%matplotlib inline
data = pd.read_csv('weight.csv')
data['Country'].value_counts().plot(kind='bar', figsize=(10,10))
연습문제 2 성별 샘플 수 pie plot으로 그리기 (figsize: 10x10, colors: blue, red)
#!python
data['Sex'].value_counts().plot(
kind='pie’,
figsize=(10,10),
colors=['blue', 'red’]
)
연습문제 3 성별로 구분하여 체중으로 histogram 그리기 (figsize: 20x10, color:gray)
#!python
data['Weight'].hist(
by=data['Sex'],
figsize=(20,10),
color=‘gray'
)
연습문제 4 국가별로 구분하여 체중으로 히스토그램 그리기 (range: 0~120, figzise:20x10, bins:20)
#!python
data['Weight'].hist(
bins=20, range=(0,120),
by=data['Country'],
figsize=(20,10)
)
연습문제 5 세 개의 서브플롯을 만들고 다음과 같이 구성
- 첫번째 서브플롯: 국가별 체중 boxplot
- 두번째 서브플롯: 체중 histogram (20 bins)
- 세번째 서브플롯: 성별 pie chart
- 서브플롯 간의 위아래 간격: 0.1
- figsize: 5,20
-
'ex5.png'로 저장
#!python import matplotlib.pyplot as plt %matplotlib inline data = pd.read_csv('weight.csv') # figure, subplot 생성 fig, axes = plt.subplots(3,1, figsize=(5,20), ) # 국가별 체충의 boxplot 그리기 data.boxplot(column='Weight', by='Country', ax=axes[0]) # 체중의 histogram 그리기 data['Weight'].hist(ax=axes[1], color='gray', bins=20, range=(0,120)) # 성별로 pie차트 그리기 data['Sex'].value_counts().plot(ax=axes[2], kind='pie') plt.subplots_adjust(hspace=0.5) #ex5.png에 저장 plt.savefig(‘ex5.png’)
유전변이 데이터(VCF) 분석 #
예제데이터
- 희귀 유전병 Pfeiffer syndrom 4가족 유전변이 데이터 Pfeiffer-quartet.vcf.gz --> http://nbviewer.jupyter.org/gist/yong27/1e18d3b07d4c7fe6b2366bfe642a3df3
- 1KG 22chr 5000개 변이 only_rs_22-5000.vcf.gz, 1KG_sample.xlsx --> http://nbviewer.jupyter.org/gist/yong27/6a9db652ed13f371cfdb3bdc4e546e82
Suggested Pages #
- 0.025 1000 Genome Project
- 0.025 May 21
- 0.025 D3.js
- 0.025 IPython
- 0.025 Pandas
- 0.025 파이썬
- 0.025 May 8
- 0.025 변이
- 0.025
- 0.025
- More suggestions...