1

I am struggling with gwasurvivr package in R. The package contains all information and running perfectly given code and its own dataset inside the vignette.

impute.file <- system.file(package="gwasurvivr",
                           "extdata",
                           "impute_example.impute2.gz")
head(impute.file)

sample.file <- system.file(package="gwasurvivr",
                           "extdata",
                           "impute_example.impute2_sample")
head(sample.file)

covariate.file <- system.file(package="gwasurvivr",
                              "extdata",
                              "simulated_pheno.txt")
head(covariate.file)

covariate.file <- read.table(covariate.file,
                             sep=" ",
                             header=TRUE,

                                                          stringsAsFactors = FALSE)

covariate.file$SexFemale <- ifelse(covariate.file$sex=="female", 1L, 0L)

sample.ids <- covariate.file[covariate.file$group=="experimental",]$ID_2
impute2CoxSurv(impute.file=impute.file,
               sample.file=sample.file,
               chr=14,
               covariate.file=covariate.file,
               id.column="ID_2",
               sample.ids=sample.ids,
               time.to.event="time",
               event="event",
               covariates=c("age", "SexFemale"),
               inter.term=NULL,
               print.covs="only",
               out.file="impute_example",
               chunk.size=50,
               maf.filter=0.005,
               exclude.snps=NULL,
               flip.dosage=TRUE,
               verbose=TRUE,
               clusterObj=NULL,
               keepGDS=FALSE)

There is no issue with above code.

I shifted some files (impute_example.impute2.gz, impute_example.impute2_sample, and simulated_pheno.txt) into a different folder. Unzipped the impute_example.impute2.gz file and tried to run the similar function, but into a new folder.

library(data.table)
impute.file <- fread("impute_example.impute2")



sample.file <- fread("impute_example.impute2_sample")

head(sample.file)


covariate.file <- read.table("simulated_pheno.txt",
                             sep=" ",
                             header=TRUE,
                             stringsAsFactors = FALSE)

covariate.file$SexFemale <- ifelse(covariate.file$sex=="female", 1L, 0L)
head(covariate.file)

sample.ids <- covariate.file[covariate.file$group=="experimental",]$ID_2

impute2CoxSurv(impute.file=impute.file,
               sample.file=sample.file,
               chr=14,
               covariate.file=covariate.file,
               id.column="ID_2",
               sample.ids=sample.ids,
               time.to.event="time",
               event="event",
               covariates=c("age", "SexFemale", "DrugTxYes"),
               inter.term=NULL,
               print.covs="only",
               out.file="impute_example",
               chunk.size=50,
               maf.filter=0.005,
               exclude.snps=NULL,
               flip.dosage=TRUE,
               verbose=TRUE,
               clusterObj=NULL,
               keepGDS=FALSE)

Now it is throwing error. Covariates included in the models are: age, DrugTxYes, SexFemale 52 samples are included in the analysis Analysis started on 2023-07-21 at 15:36:06 Determining number of SNPs and samples... Error in count.fields(input.files[1]) : 'file' must be a character string or connection Timing stopped at: 0 0 0

Tried multiple things but still struggling to fix the code or file.

Thank you in advance for your guidance.

Mark
  • 7,785
  • 2
  • 14
  • 34
Sandeep
  • 73
  • 2

1 Answers1

0

I figured out my mistake. Rather than reading impute and sample files, I have to give a path.

impute.file <- "SANDEEP/WORK/ONLINE CLASSES/Bioinformatics/Surv_GWAS/impute_example.impute2"



head(impute.file)

sample.file <- "SANDEEP/WORK/ONLINE CLASSES/Bioinformatics/Surv_GWAS/impute_example.impute2_sample"
head(sample.file)

covariate.file <- "SANDEEP/WORK/ONLINE CLASSES/Bioinformatics/Surv_GWAS/simulated_pheno.txt"
head(covariate.file)

covariate.file <- read.table(covariate.file,
                             sep=" ",
                             header=TRUE,
                             
                             stringsAsFactors = FALSE)

covariate.file$SexFemale <- ifelse(covariate.file$sex=="female", 1L, 0L)

sample.ids <- covariate.file[covariate.file$group=="experimental",]$ID_2
impute2CoxSurv(impute.file=impute.file,
               sample.file=sample.file,
               chr=14,
               covariate.file=covariate.file,
               id.column="ID_2",
               sample.ids=sample.ids,
               time.to.event="time",
               event="event",
               covariates=c("age", "SexFemale"),
               inter.term=NULL,
               print.covs="only",
               out.file="impute_example",
               chunk.size=50,
               maf.filter=0.005,
               exclude.snps=NULL,
               flip.dosage=TRUE,
               verbose=TRUE,
               clusterObj=NULL,
               keepGDS=FALSE)
Sandeep
  • 73
  • 2