0

I have a GWAS data summary results that have the following information and want to extract a list of first 120 SNPs according to p-value in R. The data have following seven headers:

SNPName    n_samplesize    A1Allele    A2Allele    beta     SE      p_value

Code via dplyr:

    library(dplyr)
    dat <- read.csv(file.choose(MetaAnalysis_Results))
    dat2 <- dat %>% arrange("p_value")

The error occurred at sorting

Update: This worked for me after converting the .csv to .txt file

    attach(MetaAnalysis_Results)
    mydata <- MetaAnalysis_Results
    new <- mydata[order(p_value),]
Tabbi
  • 59
  • 8

1 Answers1

0

the easiest way to do this is to use dplyr. Install it if not existed

install.packages("dplyr")

    library(dplyr)
    dat <- read.csv(file.choose())

    #Make sure the data is imported
    head(dat)

    dat <- dat %>% arrange("p_values")
    dat2 <- dat[1:120,]
    write.csv(dat2)
Omar113
  • 198
  • 7