### Commands for R Intro # Using R as a basic calculator 2+3 1+2*3 4^2 exp(1) log(100) log(100, base=10) # Assignments a = 5 b = 3 a a-2*b a = a+1 a # Vectors c(3, 2, 6, -1) 4:20 5:7 - 4 c(10,20,30,40) + c(1,3,8,0) seq(from=2, to=15, by=3) seq(10, by=2, length=5) seq(10, 0, by=-2) 5:(-5) # Lists a = list(good=1:3, bad=0) a a$good a$bad = NULL a$ok = -1 a$good = c(a$good, 10) a # Basic plotting x = seq(-2, 2, length=100) y = x^2 plot(x, y) plot(x, y, type="l", lwd=3, col="red", ylab="x squared", main="My plot!") # Installing. loading packages # install.packages(ʺparamlinkʺ) library(paramlink) #paramlink x = cousinsPed(2) plot(x) x2 = swapSex(x, 7) x3 = swapSex(x, c(3,5,7)) plot(x3) #Lets play x = nuclearPed(3, sex=c(1,2,1)) plot(x) x = addDaughter(x, 2) plot(x) x = addOffspring(x, father=5, mother=7, noffs=1, sex=2) plot(x) #Markers x = nuclearPed(3, sex=c(1,2,1)) m = marker(x, 1, c('A','B')) plot(x, m) m2 = marker(x, 1, 'A', 4, c('A','B'), c(3,5), 'B', chrom=23) plot(x, m2) #likehood computation x = nuclearPed(3, sex=c(1,2,1)) m = marker(x, 1, c('A','B')) m likelihood(x, m) 2*0.5*0.5 #Practical example library(paramlink) y = halfCousinPed(degree=1) y = swapSex(y,9) snp = marker(y, 9, c('D','D'), alleles=c('D', 'N'), afreq=c(0.01, 0.99)) plot(y,snp) #Simple plot oneMarkerDistribution(y, ids=8, partialmarker=snp)