Create_Single_SNP_Object: For a single SNP, create an SNPFastImpute Object

Description Usage Arguments Details Value Examples

View source: R/Create_SNP_XGBoost_Object_function.R

Description

For a single SNP, create an SNPFastImpute Object

Usage

1
Create_Single_SNP_Object(df, a, size, cor.matrix = NULL)

Arguments

df

the dataframe containing NAs, p columns of SNPs, n rows of samples.

a

the column indicator of the SNP in the dataset.

size

the windows size around the SNP to use as predictor variables.

cor.matrix

A matrix storing the correlation of all SNPs in the dataframe. Defualt is NULL, which is to just use the SNPs around the target SNP to build model. When given this matrix, we pick the top n = size highest correlated columns to build model.

Details

Basically the function do two different jobs. Using the known values for each SNP to predict the missing values for that SNP.

Value

an object for the corresponding SNP.

If the SNP has missing value, then this object is a list with 6 elements:

1. model_fit: indicator whether we need to fit a model for the SNP. 2. SNP_position: position of the SNP. 3. NA_positions: position of the missing values. 4. train_data: samples that are not missing for this SNP. 5. train_lable: the values of the non-missing samples for this SNP 6. pred_data: samples that are missing for this SNP. 7. pred_label: an empty vector to store the future predicted labels. 8. windows_range: the range of surrounding SNPs used for model building.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
data("Test_df")
single_SNP_Obj <- Create_Single_SNP_Object(Test_df, 1, 10)
## return a list of SNP related information for model building.

Create_Single_SNP_Object(Test_df, 50, 200)
## Error message. 
## Stop as the size of the windows are larger than the number of SNPs in the dataframe. 

Create_Single_SNP_Object(matrix(NA, 10, 5), 1, 1)
## Should print a warning message that all samples for this SNP are NA's.
## return a list containing a model_fit value equal to false. 

corr <- cor(Test_df, method = "spearman", use = "pairwise.complete.obs")
Create_Single_SNP_Object(Test_df, 3, 20, cor.matrix = corr)
Create_Single_SNP_Object(Test_df, 3, 20)

GaoGN517/689_SNP_FastImpute documentation built on Jan. 2, 2020, 11:44 a.m.