hlaModelFromObj: Conversion between the in-memory model and the object that...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/HIBAG.R

Description

Build a model hlaAttrBagClass from an object of hlaAttrBagObj which is stored in an R object file, or convert hlaAttrBagClass to hlaAttrBagObj.

Usage

1
2

Arguments

obj

an object of hlaAttrBagObj

model

an object of hlaAttrBagClass

Value

hlaModelFromObj returns hlaAttrBagClass, and hlaModelToObj returns hlaAttrBagObj.

Author(s)

Xiuwen Zheng

See Also

hlaAttrBagging

Examples

 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
# make a "hlaAlleleClass" object
hla.id <- "DQB1"
hla <- hlaAllele(HLA_Type_Table$sample.id,
    H1 = HLA_Type_Table[, paste(hla.id, ".1", sep="")],
    H2 = HLA_Type_Table[, paste(hla.id, ".2", sep="")],
    locus=hla.id, assembly="hg19")

# training genotypes
region <- 100   # kb
snpid <- hlaFlankingSNP(HapMap_CEU_Geno$snp.id, HapMap_CEU_Geno$snp.position,
    hla.id, region*1000, assembly="hg19")
train.geno <- hlaGenoSubset(HapMap_CEU_Geno,
    snp.sel = match(snpid, HapMap_CEU_Geno$snp.id))

# train a HIBAG model
set.seed(1000)
model <- hlaAttrBagging(hla, train.geno, nclassifier=2)
print(model)

mobj <- hlaModelToObj(model)

is(model)
is(mobj)


# close the HIBAG model explicitly
hlaClose(model)

Example output

HIBAG (HLA Genotype Imputation with Attribute Bagging)
Kernel Version: v1.5 (64-bit, AVX2)
Exclude 1 monomorphic SNP
Build a HIBAG model with 2 individual classifiers:
    # of SNPs randomly sampled as candidates for each selection: 9
    # of SNPs: 77
    # of samples: 60
    # of unique HLA alleles: 12
CPU flags: 64-bit, AVX2
# of threads: 1
[-] 2021-07-02 22:48:36
=== building individual classifier 1, out-of-bag (25/41.7%) ===
[1] 2021-07-02 22:48:36, OOB Acc: 98.00%, # of SNPs: 13, # of Haplo: 20
=== building individual classifier 2, out-of-bag (22/36.7%) ===
[2] 2021-07-02 22:48:36, OOB Acc: 90.91%, # of SNPs: 15, # of Haplo: 21
Calculating matching proportion:
        Min.     0.1% Qu.       1% Qu.      1st Qu.       Median      3rd Qu. 
7.678603e-08 2.465759e-05 2.458848e-04 5.217343e-03 1.419916e-02 2.994924e-02 
        Max.         Mean           SD 
4.728168e-01 4.409445e-02 1.068815e-01 
Accuracy with training data: 95.00%
Out-of-bag accuracy: 94.45%
Gene: DQB1
Training dataset: 60 samples X 77 SNPs
    # of HLA alleles: 12
    # of individual classifiers: 2
    total # of SNPs used: 20
    avg. # of SNPs in an individual classifier: 14.00
        (sd: 1.41, min: 13, max: 15, median: 14.00)
    avg. # of haplotypes in an individual classifier: 20.50
        (sd: 0.71, min: 20, max: 21, median: 20.50)
    avg. out-of-bag accuracy: 94.45%
        (sd: 5.01%, min: 90.91%, max: 98.00%, median: 94.45%)
Matching proportion:
        Min.     0.1% Qu.       1% Qu.      1st Qu.       Median      3rd Qu. 
7.678603e-08 2.465759e-05 2.458848e-04 5.217343e-03 1.419916e-02 2.994924e-02 
        Max.         Mean           SD 
4.728168e-01 4.409445e-02 1.068815e-01 
Genome assembly: hg19
[1] "hlaAttrBagClass"
[1] "hlaAttrBagObj"

HIBAG documentation built on March 24, 2021, 6 p.m.