+ All Categories
Home > Health & Medicine > iHS calculation in R

iHS calculation in R

Date post: 24-Jan-2017
Category:
Upload: jinseob-kim
View: 305 times
Download: 1 times
Share this document with a friend
6
iHS.R secondmath Tue Oct 28 20:23:05 2014 ############## 2014 SNU GEPI population genetics by Jinseob Kim ################### ############## 2. EHH, iHS calculation ################################################## ## Load package & Set directory #install.packages("rehh") library(rehh) ## Loading required package: gplots ## ## Attaching package: gplots ## ## The following object is masked from package:stats: ## ## lowess setwd("/home/secondmath/Dropbox/GSPH/myteaching/pop_gene/2012") ## Read example file, chr=12: 1424 SNPs & 280 haplotype a=data2haplohh(hap_file="prac_hap.hap",map_file="prac_map.inp",min_maf=0,chr=12) ## Map file seems OK: 1424 SNPs declared for chromosome 12 ## Standard rehh input file assumed ## Data consists of 280 haplotypes and 1424 SNPs ## EHH par(mfrow=c(1,2)) res1=calc_ehh(a,mrk=456,limhaplo=2,limehh=0.05,plotehh=TRUE,main_leg="EHH plot") res11=calc_ehhs(a,mrk=456,limhaplo=2,limehh=0.05,plotehh=TRUE,main_leg="EHHS plot") # site EHH 1
Transcript
Page 1: iHS calculation in R

iHS.Rsecondmath

Tue Oct 28 20:23:05 2014

############## 2014 SNU GEPI population genetics by Jinseob Kim ################################# 2. EHH, iHS calculation ##################################################

## Load package & Set directory#install.packages("rehh")library(rehh)

## Loading required package: gplots#### Attaching package: 'gplots'#### The following object is masked from 'package:stats':#### lowess

setwd("/home/secondmath/Dropbox/GSPH/myteaching/pop_gene/2012")

## Read example file, chr=12: 1424 SNPs & 280 haplotypea=data2haplohh(hap_file="prac_hap.hap",map_file="prac_map.inp",min_maf=0,chr=12)

## Map file seems OK: 1424 SNPs declared for chromosome 12## Standard rehh input file assumed## Data consists of 280 haplotypes and 1424 SNPs

## EHHpar(mfrow=c(1,2))res1=calc_ehh(a,mrk=456,limhaplo=2,limehh=0.05,plotehh=TRUE,main_leg="EHH plot")res11=calc_ehhs(a,mrk=456,limhaplo=2,limehh=0.05,plotehh=TRUE,main_leg="EHHS plot") # site EHH

1

Page 2: iHS calculation in R

2.6e+07 2.8e+07 3.0e+07

0.0

0.2

0.4

0.6

0.8

1.0

EHH plot

Position

EH

H

Anc. AlleleDer. Allele

2.6e+07 2.8e+07 3.0e+07

0.2

0.4

0.6

0.8

1.0

EHHS plot

Position

EH

HS

## Integrated EHHres2=scan_hh(a) # a: ancestral, d: derived, IES: average of IHHa & IHHd (squared allele freq weighted)head(res2)

## CHR POSITION FREQ_a IHHa IHHd IES## F1200140 12 79823 0.1500000 135102.2 68522.91 69777.21## F1200150 12 125974 0.4071429 161680.3 107183.15 123610.30## F1200170 12 175087 0.3571429 157333.1 155777.56 156094.80## F1200180 12 219152 0.2214286 250037.4 159839.73 166333.27## F1200190 12 256896 0.1750000 466071.8 173269.33 184501.30## F1200210 12 316254 0.3892857 292077.5 228681.21 246790.48

## iHSihs_res2=ihh2ihs(res2)head(ihs_res2$res.ihs) ## iHS & pvalue

## CHR POSITION iHS Pvalue## F1200140 12 79823 0.3222762 0.12653788## F1200150 12 125974 0.8177351 0.38351558## F1200170 12 175087 -0.1370753 0.05013628## F1200180 12 219152 0.7830146 0.36289214## F1200190 12 256896 1.7890234 1.13305700## F1200210 12 316254 0.6819630 0.30516469

ihs_res2$summary.class ## summary per alle freq bin.

## Freq Class Size Mean iHH SD iHH

2

Page 3: iHS calculation in R

## [1,] "0.05 - 0.075" "60" "0.777287796382857" "0.737413595194812"## [2,] "0.075 - 0.1" "52" "0.435963216395243" "0.641021685121639"## [3,] "0.1 - 0.125" "53" "0.332371980508715" "0.494815167465929"## [4,] "0.125 - 0.15" "56" "0.49169123696354" "0.580781486711665"## [5,] "0.15 - 0.175" "36" "0.338272919812911" "0.557299171859519"## [6,] "0.175 - 0.2" "38" "0.18372872314435" "0.450393024202394"## [7,] "0.2 - 0.225" "37" "0.156221814866492" "0.371917601032433"## [8,] "0.225 - 0.25" "36" "0.324937638464128" "0.491539213848196"## [9,] "0.25 - 0.275" "35" "0.198821549387942" "0.53358843127552"## [10,] "0.275 - 0.3" "30" "0.0277095221301871" "0.549619811280544"## [11,] "0.3 - 0.325" "42" "0.168813465351846" "0.512617332536968"## [12,] "0.325 - 0.35" "47" "0.212561823991102" "0.334091037846137"## [13,] "0.35 - 0.375" "35" "0.0778960787783505" "0.495788198190895"## [14,] "0.375 - 0.4" "34" "0.0142114538338362" "0.337963648645465"## [15,] "0.4 - 0.425" "37" "-0.0135618204249136" "0.519292818010164"## [16,] "0.425 - 0.45" "29" "0.146848067738759" "0.387610402411398"## [17,] "0.45 - 0.475" "34" "0.023234914963773" "0.462855711456721"## [18,] "0.475 - 0.5" "22" "-0.0280038381405699" "0.597672428815518"## [19,] "0.5 - 0.525" "21" "0.0676757215676396" "0.397285061426881"## [20,] "0.525 - 0.55" "22" "-0.0119346374773765" "0.475444749317303"## [21,] "0.55 - 0.575" "23" "-0.119650040006845" "0.456309312077108"## [22,] "0.575 - 0.6" "27" "-0.208393804329524" "0.627878921699334"## [23,] "0.6 - 0.625" "31" "-0.175432335220113" "0.431580562389071"## [24,] "0.625 - 0.65" "31" "-0.114913122059472" "0.362470027772815"## [25,] "0.65 - 0.675" "21" "0.0183870416195869" "0.545114444067057"## [26,] "0.675 - 0.7" "37" "-0.241776665581487" "0.445729962977197"## [27,] "0.7 - 0.725" "18" "-0.262633365184881" "0.314960709993038"## [28,] "0.725 - 0.75" "24" "-0.276070830019936" "0.406614904878564"## [29,] "0.75 - 0.775" "29" "-0.344832955793417" "0.475726025499208"## [30,] "0.775 - 0.8" "19" "-0.326154359766926" "0.437583935197108"## [31,] "0.8 - 0.825" "28" "-0.197815151810967" "0.61906090927441"## [32,] "0.825 - 0.85" "26" "-0.407636344735006" "0.591045435108097"## [33,] "0.85 - 0.875" "20" "-0.116549521453988" "0.597016190918244"## [34,] "0.875 - 0.9" "42" "-0.374897066174067" "0.508197119111094"## [35,] "0.9 - 0.925" "29" "-0.796408081584825" "0.804739382631854"## [36,] "0.925 - 0.95" "36" "-0.693833406890539" "0.639986265748046"

ihsplot(ihs_res2$res.ihs) ## iHS plot: y- pvalue, x-bp

3

Page 4: iHS calculation in R

−4

−2

0

2

iHS

Chromosome

iHS

12

0

1

2

3

4

Pvalue

Chromosome

−lo

g 10[

1−

2|Φ

iHS−

0.5|

]12

## Rsb & iHS : using wgscan example's resultdata(wgscan.cgu) ; data(wgscan.eut) ## Load example resulthead(wgscan.cgu)

## BTA POSITION Freq_1 IHH_1 IHH_2 IES## F0100190 1 113642 0.5429 319186.5 395166.8 350741.0## F0100220 1 244699 0.2607 465943.5 377422.8 385189.1## F0100250 1 369419 0.2964 518137.2 372117.0 396350.0## F0100270 1 447278 0.1071 742502.6 318958.0 323906.8## F0100280 1 487654 0.3857 542176.3 364969.2 412955.4## F0100290 1 524507 0.8429 375305.8 572230.2 380989.9

head(wgscan.eut)

## BTA POSITION Freq_1 IHH_1 IHH_2 IES## F0100190 1 113642 0.3528 331082.8 340341.6 338224.1## F0100220 1 244699 0.3264 382078.2 434030.9 424800.2## F0100250 1 369419 0.1226 416906.0 372273.8 372756.1## F0100270 1 447278 0.4208 662485.5 337043.8 436346.3## F0100280 1 487654 0.2321 458545.6 379588.7 386265.6## F0100290 1 524507 0.8396 393546.0 526026.7 399238.6

res.rsb=ies2rsb(wgscan.cgu,wgscan.eut,"CGU","EUT") ## Rsb: Compare 2 populationhead(res.rsb$res.rsb)

## BTA POSITION rSB (CGU vs EUT) Pvalue (bilateral)## F0100190 1 113642 -0.3653553 0.14578738

4

Page 5: iHS calculation in R

## F0100220 1 244699 -0.9188850 0.44592808## F0100250 1 369419 -0.2621161 0.10059980## F0100270 1 447278 -1.7440674 1.09072568## F0100280 1 487654 -0.2396774 0.09120393## F0100290 1 524507 -0.7081588 0.31980358

rsbplot(res.rsb$res.rsb) ## Rsb plot

−5

0

5

rSB (CGU vs EUT)

Chromosome

rSB

1 4 7 11 17 24

0

2

4

6

8

10

12

14

Pvalue

Chromosome

−lo

g 10[

1−

2|Φ

rSB−

0.5|

]

1 4 7 11 17 24

## all chr iHS plot in wgscan.cgu dataihs_res3=ihh2ihs(wgscan.cgu)ihsplot(ihs_res3$res.ihs)

5

Page 6: iHS calculation in R

−6

−4

−2

0

2

4

iHS

Chromosome

iHS

1 4 7 11 17 24

0

2

4

6

8

Pvalue

Chromosome

−lo

g 10[

1−

2|Φ

iHS−

0.5|

]1 4 7 11 17 24

6


Recommended