I am still new with RStudio, i will appreciate if someone give me an idea
setwd("~/lastversion_gwas_analysis/F_95/trial/")
source("gwas.r")
source("emma.r")
source("plots_gwas.r")
source('~/lastversion_gwas_analysis/f95_gwas.r')
#load Y values
temp = list.files(pattern="*.csv")
for (i in 1:length(temp)) assign(temp[i], read.csv(temp[i]))
#i can just put one .csv file as a Y value inside f95_gwas() r file.
Y<- AT5G66980_AT4G10370.csv
Y[,1]<-as.numeric(Y[,1])
Y[,2]<-as.numeric(Y[,2])
f95_gwas(Y) #in this command gwas is running'''
#in here i tried to to put into list then call them separetly but i didnt find any solution yet. i need to use this for thousand differnt .csv file and put separelty inside f95_gwas () as a Y value
library(tidyverse)
library(fs)
source("gwas.r")
source("emma.r")
source("plots_gwas.r")
source('~/lastversion_gwas_analysis/f95_gwas.r')
setwd("~/lastversion_gwas_analysis/F_95/trial/")
file_paths<-fs::dir_ls("~/lastversion_gwas_analysis/F_95/trial/")
file_paths
##for loop
Y <- list()
for(i in seq_along(file_paths)){
Y[[i]]<-read_csv(
file=file_paths[[i]]
)
}
Y<-set_names(Y, file_paths)
for (i in 1:length(Y))
{
f95_gwas(Y[i]) #in this command gwas is running
}
I wasnt sure to put into loop like this, it was just an idea but it give me an Error in Y[,1]: incorrect number of dimensions. So i need to use these different .csv files as a separate Y value into the f95_gwas funtion.
Thank you for your answer, i also tried with double brackets but it still give me an error:
Error in Y[,1]: incorrect number of dimensions.
So i think i need to find a different approach to put different files into loop as a seperate Y value into the funtion f95_gwas().
I think i shouldn't try to put f95_gwas(Y[[i]]). Instead of this i need to put directlt f95_gwas(Y) so maybe i shouldnt create an list in the first place to put all these file in the list.
I do not see similar lines processing the first two columns with as.numeric() when you are using the loop. That may be the cause of the error.
It is certainly possible to combine your two loops so that you use read_csv() to assign the content of a file to Y and then process Y with f95_gwas() (including using as.numeric() to change the first two columns).
I notice that you do not assign the result of f95_gwas() to anything. That might be alright, depending on what the function does, but I mention it because it is a common error to forget to assign the function's returned value.