-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIMPUTE2_GRM.R
43 lines (22 loc) · 1.48 KB
/
IMPUTE2_GRM.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#######################################################################################################################################
# Intro on working with big tables using FF:
#
# Dunia - Roberto - et.al
#
#######################################################################################################################################
#Load library
library(ff)
# create and ff object from a table, in this case IMPUTE2.ready is a Dosage file with individuals as columns and markers as rows
CBSD_Impute2 <- read.table.ffdf(file = "IMPUTE2.ready", header=TRUE, sep="\t", first.rows= 100000, next.rows = 150000, VERBOSE = TRUE)
# Save the ffobject, this might take long and will create a lot of *ff files plus CBSD_ff.ffData and CBSD_ff.RData
# You will always have to setwd to the place where you create the *ff files in order to load the ff object
ffsave(GGC1_Impute2, file = "GGC1_ff")
# Loading the ff object
ffload("CBSD_ff")
# Virtual transpose (vt()) (where <ffobject> is the name of your object, for this example it is "CBSD_Impute2)
tff <- vt(CBSD_Impute2)
# Operations using ff objects
# If you want to do operation into the ffobject just add "[]" after it so for example to calculate the relationship matrix do:
library(rrBLUP)
I2_GRM <- A.mat(CBSD_Impute2[] -1)
#######################################################################################################################################