p. adjust for multiple columns in the same dataframe in R

kllrdr

I have a dataframe with hundreds of p values I want to compute FDR significance for.

My dataframe:

Trait p-value1 p-value2 p-value3 pvalue4
1 0.5 0.01 0.1 0.12
2 0.1 0.9 0.4 0.32
3 0.2 0.45 0.34 0.45
4 0.2 0.02 0.22 0.11

I do it separately for each column with the following script (example on p-value1):

fdr <- p.adjust (p-value1, method = "fdr", n = length(p-value1)) 

How can I do it for all columns at the same time?

AnilGoyal

Assuming that you need not do it for PK i.e. trait column. Try this in R version 4.1.0

lapply(my_df[-1], \(x) p.adjust (x, method = "fdr", n = length(x)))

OR this in older versions

lapply(my_df[-1], function(x) p.adjust (x, method = "fdr", n = length(x)))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

R ggplot - plot all columns of dataframe as multiple lines with the same color

Merge multiple columns in same DataFrame

Recode multiple columns in dataframe R

Split a dataframe in multiple columns in R

Combining multiple columns with same name in pandas dataframe

How to factorize multiple dataframe columns with same values?

Apply forward to multiple columns in dataframe with the same name

Pandas map groupby with multiple columns in same dataframe

Joining Multiple columns of same dataframe in python

How to adjust dataframe rows to columns

how to match values in columns by group or within category (groupwise) with other column(having multiple values) in same dataframe in R

Upload multiple csv files and select same columns from each into one dataframe in R?

How to replace values of multiple columns with other columns within the same dataframe?

Apply the same function with multiple columns as inputs to multiple columns in R with tidyverse

How to create multiple additional columns from dataframe and add to the same dataframe

Is there an R function for pivoting multiple columns to the same row?

R - Applying the Same Code to Multiple Columns

R dplyr with multiple columns with same stem name

Filter multiple columns based on same criteria in R

R - Subtract the same value from multiple columns

R - Applying same function on multiple columns

|R] Select multiple columns starting with the same pattern

Modify multiple columns at same time in R

Applying function to multiple dataframe columns in R

R - substr over multiple columns in Dataframe

Mutate over multiple selected columns of a dataframe in R

Percentage group by for multiple columns in R dataframe

Sorting by multiple columns not working - R Dataframe

R - Split a one column dataframe into multiple columns