A method to get a subset (copy) of a bigSNP. This new bigSNP will also be backed by files (in the same directory).

# S3 method for bigSNP
subset(x, ind.row = rows_along(G),
  ind.col = cols_along(G), ...)

Arguments

x

A bigSNP.

ind.row

Indices of the rows (individuals) to keep. Negative indices can be used to exclude row indices. Default: keep them all.

ind.col

Indices of the columns (SNPs) to keep. Negative indices can be used to exclude column indices. Default: keep them all.

...

Not used.

Value

The path to the RDS file that stores the bigSNP object.
Note that this function creates two files whose names have been automatically chosen by appending "_sub" and a number to the prefix of the input bigSNP backing files.

See also

Examples

#> List of 3 #> $ genotypes:Reference class 'FBM.code256' [package "bigstatsr"] with 10 fields #> ..$ extptr :<externalptr> #> ..$ nrow : int 517 #> ..$ ncol : int 4542 #> ..$ type : Named int 1 #> .. ..- attr(*, "names")= chr "unsigned char" #> ..$ backingfile: chr "/tmp/RtmpHMIGXH/file272e50d3b8af.bk" #> ..$ address :<externalptr> #> ..$ bk : chr "/tmp/RtmpHMIGXH/file272e50d3b8af.bk" #> ..$ rds : chr "/tmp/RtmpHMIGXH/file272e50d3b8af.rds" #> ..$ is_saved : logi TRUE #> ..$ code256 : num [1:256] 0 1 2 NA NA NA NA NA NA NA ... #> ..and 24 methods, of which 10 are possibly relevant: #> .. add_columns, as.FBM, bm, bm.desc, copy#envRefClass, initialize, #> .. initialize#FBM, save, show#envRefClass, show#FBM #> $ fam :'data.frame': 517 obs. of 6 variables: #> ..$ family.ID : chr [1:517] "POP1" "POP1" "POP1" "POP1" ... #> ..$ sample.ID : chr [1:517] "IND0" "IND1" "IND2" "IND3" ... #> ..$ paternal.ID: int [1:517] 0 0 0 0 0 0 0 0 0 0 ... #> ..$ maternal.ID: int [1:517] 0 0 0 0 0 0 0 0 0 0 ... #> ..$ sex : int [1:517] 0 0 0 0 0 0 0 0 0 0 ... #> ..$ affection : int [1:517] 1 1 2 1 1 1 1 1 1 1 ... #> $ map :'data.frame': 4542 obs. of 6 variables: #> ..$ chromosome : int [1:4542] 1 1 1 1 1 1 1 1 1 1 ... #> ..$ marker.ID : chr [1:4542] "SNP0" "SNP1" "SNP2" "SNP3" ... #> ..$ genetic.dist: int [1:4542] 0 0 0 0 0 0 0 0 0 0 ... #> ..$ physical.pos: int [1:4542] 112 1098 2089 3107 4091 5091 6107 7103 8090 9074 ... #> ..$ allele1 : chr [1:4542] "A" "T" "T" "T" ... #> ..$ allele2 : chr [1:4542] "T" "A" "A" "A" ... #> - attr(*, "class")= chr "bigSNP"
# keep only first 50 samples and SNPs rdsfile <- subset(test, ind.row = 1:50, ind.col = 1:50) str(snp_attach(rdsfile))
#> List of 3 #> $ genotypes:Reference class 'FBM.code256' [package "bigstatsr"] with 10 fields #> ..$ extptr :<externalptr> #> ..$ nrow : int 50 #> ..$ ncol : int 50 #> ..$ type : Named int 1 #> .. ..- attr(*, "names")= chr "unsigned char" #> ..$ backingfile: chr "/tmp/RtmpHMIGXH/file272e50d3b8af_sub1.bk" #> ..$ address :<externalptr> #> ..$ bk : chr "/tmp/RtmpHMIGXH/file272e50d3b8af_sub1.bk" #> ..$ rds : chr "/tmp/RtmpHMIGXH/file272e50d3b8af_sub1.rds" #> ..$ is_saved : logi TRUE #> ..$ code256 : num [1:256] 0 1 2 NA NA NA NA NA NA NA ... #> ..and 24 methods, of which 10 are possibly relevant: #> .. add_columns, as.FBM, bm, bm.desc, copy#envRefClass, initialize, #> .. initialize#FBM, save, show#envRefClass, show#FBM #> $ fam :'data.frame': 50 obs. of 6 variables: #> ..$ family.ID : chr [1:50] "POP1" "POP1" "POP1" "POP1" ... #> ..$ sample.ID : chr [1:50] "IND0" "IND1" "IND2" "IND3" ... #> ..$ paternal.ID: int [1:50] 0 0 0 0 0 0 0 0 0 0 ... #> ..$ maternal.ID: int [1:50] 0 0 0 0 0 0 0 0 0 0 ... #> ..$ sex : int [1:50] 0 0 0 0 0 0 0 0 0 0 ... #> ..$ affection : int [1:50] 1 1 2 1 1 1 1 1 1 1 ... #> $ map :'data.frame': 50 obs. of 6 variables: #> ..$ chromosome : int [1:50] 1 1 1 1 1 1 1 1 1 1 ... #> ..$ marker.ID : chr [1:50] "SNP0" "SNP1" "SNP2" "SNP3" ... #> ..$ genetic.dist: int [1:50] 0 0 0 0 0 0 0 0 0 0 ... #> ..$ physical.pos: int [1:50] 112 1098 2089 3107 4091 5091 6107 7103 8090 9074 ... #> ..$ allele1 : chr [1:50] "A" "T" "T" "T" ... #> ..$ allele2 : chr [1:50] "T" "A" "A" "A" ... #> - attr(*, "class")= chr "bigSNP"
# remove only first 50 samples and SNPs rdsfile2 <- subset(test, ind.row = -(1:50), ind.col = -(1:50)) str(snp_attach(rdsfile2))
#> List of 3 #> $ genotypes:Reference class 'FBM.code256' [package "bigstatsr"] with 10 fields #> ..$ extptr :<externalptr> #> ..$ nrow : int 467 #> ..$ ncol : int 4492 #> ..$ type : Named int 1 #> .. ..- attr(*, "names")= chr "unsigned char" #> ..$ backingfile: chr "/tmp/RtmpHMIGXH/file272e50d3b8af_sub2.bk" #> ..$ address :<externalptr> #> ..$ bk : chr "/tmp/RtmpHMIGXH/file272e50d3b8af_sub2.bk" #> ..$ rds : chr "/tmp/RtmpHMIGXH/file272e50d3b8af_sub2.rds" #> ..$ is_saved : logi TRUE #> ..$ code256 : num [1:256] 0 1 2 NA NA NA NA NA NA NA ... #> ..and 24 methods, of which 10 are possibly relevant: #> .. add_columns, as.FBM, bm, bm.desc, copy#envRefClass, initialize, #> .. initialize#FBM, save, show#envRefClass, show#FBM #> $ fam :'data.frame': 467 obs. of 6 variables: #> ..$ family.ID : chr [1:467] "POP2" "POP2" "POP2" "POP2" ... #> ..$ sample.ID : chr [1:467] "IND50" "IND51" "IND52" "IND53" ... #> ..$ paternal.ID: int [1:467] 0 0 0 0 0 0 0 0 0 0 ... #> ..$ maternal.ID: int [1:467] 0 0 0 0 0 0 0 0 0 0 ... #> ..$ sex : int [1:467] 0 0 0 0 0 0 0 0 0 0 ... #> ..$ affection : int [1:467] 1 1 2 1 1 1 1 1 1 2 ... #> $ map :'data.frame': 4492 obs. of 6 variables: #> ..$ chromosome : int [1:4492] 1 1 1 1 1 1 1 1 1 1 ... #> ..$ marker.ID : chr [1:4492] "SNP50" "SNP51" "SNP52" "SNP53" ... #> ..$ genetic.dist: int [1:4492] 0 0 0 0 0 0 0 0 0 0 ... #> ..$ physical.pos: int [1:4492] 50100 51109 52101 53106 54101 55097 56103 57110 58101 59088 ... #> ..$ allele1 : chr [1:4492] "A" "A" "A" "T" ... #> ..$ allele2 : chr [1:4492] "T" "T" "T" "A" ... #> - attr(*, "class")= chr "bigSNP"