This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Error: Can't subset columns that don't exist.

Hi All, I have the following dataframe:

> head(allTF_NFIC_TPM_df)
  Gene     Sample      TPM    TF Genotype
1 Nfic SRR4103512 2.097590 Ptf1a       WT
2 Nfic SRR4103513 1.989032 Ptf1a       WT
3 Nfic SRR4103514 0.475040 Ptf1a       WT
4 Nfic SRR4103515 0.498004 Ptf1a       WT
5 Nfic SRR4103516 0.588734 Ptf1a       WT
6 Nfic SRR4103517 0.820988 Ptf1a       KO

The TF column has three subgroups: Ptf1a, Mist1, and Nr5a2. Within each subgroup, I want to compare TPM values between WT and KO. Thus, I executed the following:

cmeans <- compare_means(TPM ~ Genotype, data = allTF_NFIC_TPM_df, method = "t.test", paired = F, group.by = TF)

However, I get an error that says:

Error: Can't subset columns that don't exist. x Column `Ptf1a` doesn't exist.

I partly understand that something's wrong with the group.by argument. I have looked around but was unable to find a solution. I hope someone from the community can help me find one. Thanks.

r ggpubr

Check if you are using correct data frame. Check if group.by column is factor and correct group.by = TF to group.by = "TF". To my understanding your function should fail with a different error unless object TF exists.

Thanks for the suggestion(s). Changing group.by = TF to group.by = "TF" worked. However, I do not understand the logic behind this.

group.by = TF (group.by existing object TF)

group.by = "TF" (group.by column TF in the data, in this context)

0 answers

No answers yet.

Log in to answer this question.