saving the correct af or script

This commit is contained in:
Tanushree Tunstall 2021-06-11 13:26:28 +01:00
parent 4e38e2a80e
commit 587be435e9

36
scripts/af_or_calcs.R Executable file → Normal file
View file

@ -71,6 +71,10 @@ cat(paste0('Output file with full path:', outfile_af_or))
######################################################### #########################################################
raw_data_all = read.csv(infile_master, stringsAsFactors = F) raw_data_all = read.csv(infile_master, stringsAsFactors = F)
# building cols to extract
dr_muts_col = paste0('dr_mutations_', drug)
other_muts_col = paste0('other_mutations_', drug)
cat('Extracting columns based on variables:\n' cat('Extracting columns based on variables:\n'
, drug , drug
, '\n' , '\n'
@ -149,8 +153,8 @@ print(paste('Dim of', deparse(substitute(gene_metadata)), ':')); print(dim(gene_
rm(in_filename_metadata, infile_metadata) rm(in_filename_metadata, infile_metadata)
# count na in drug column # count na in drug column
tot_pza_na = sum(is.na(gene_metadata[[drug]])) tot_drug_na = sum(is.na(gene_metadata[[drug]]))
expected_rows = nrow(gene_metadata) - tot_pza_na expected_rows = nrow(gene_metadata) - tot_drug_na
# drop na from the drug column # drop na from the drug column
gene_snps_or = gene_metadata[!is.na(gene_metadata[[drug]]),] gene_snps_or = gene_metadata[!is.na(gene_metadata[[drug]]),]
@ -213,23 +217,19 @@ pval_logistic = summary(model)$coefficients[2,4]
print(paste0('logistic pval:', pval_logistic)) print(paste0('logistic pval:', pval_logistic))
#===================================== #=====================================
# OR calcs using the following 4 #OR calcs using the following 4
#1) logistic #1) chisq.test
#2) custom chisq.test #2) fisher
#3) fisher #3) modified chisq.test
#4) chisq.test #4) logistic
#5) adjusted logistic?
# adjusted logistic (NO good) #6) kinship (separate script)
# kinship (separate script) #=====================================
#====================================== #snps <- gene_snps_unique[1:2]# TEST FOR a few muts
# TEST FOR a few muts: sapply and df
#======================================
#snps <- gene_snps_unique[1:2]# reassign so you test with subset of muts
snps <- gene_snps_unique snps <- gene_snps_unique
cat(paste0('Running calculations for:' cat(paste0('Running calculations for:', length(snps), ' nssnps\n'
, length(snps), ' nssnps\n' , 'gene: ', gene
, 'gene: ', gene , '\ndrug: ', drug ))
, '\ndrug: ', drug ))
# DV: <drug> 0 or 1 # DV: <drug> 0 or 1
dst = raw_data[[drug]] dst = raw_data[[drug]]