Why this ballgown error (first column of pData does not match the names of the folders) comes out I am trying to create a ballgown object, and I would like to set a phenodata information.
For that I do 

phenodata &lt;- read.csv('l002.csv')


and my l002.csv file contains the following info

id,state
RNA-CCC_8N_S5_L002,control
RNA-CCC_8T1_S6_L002,tube
RNA-CCC_12N_S7_L002,control
RNA-CCC_12T_S8_L002,tube
RNA-CCC_13N_S105_L002,control
RNA-CCC_13T_S106_L002,tube
RNA-CCC_23N_S107_L002,control
RNA-CCC_23T_S108_L002,tube


A ballgown folder contains folders that have exactly the same names, e.g. RNA-CCC_8N_S5_L002, RNA-CCC_8T1_S6_L002, etc...
Then, I use this piece of code for bg object creation

bg = ballgown(dataDir = "ballgown", samplePattern = "RNA-CCC_", pData = phenodata )


but every time I run it, I have the same error every time:

Error in ballgown(dataDir = "ballgown", samplePattern = "RNA-CCC_", pData = phenodata) : 
  first column of pData does not match the names of the folders containing the ballgown data.


What can be a problem since first column of pData matches exactly the names of the folders containing the ballgown data.. 

If I get rid of phenodata ballgown object creation works, but I need this phenodata for further manipulations.
Well, it looks like if you're using Windows for managing files - that's not a good idea - it sorts names of your ballgown folders in alphabetical order while you need it differently. 

That is why the one should use Linux - when you're ls -ltr your ballgown folder in Linux it gives you the "right" sequence of folder names to be put inside a ballgown object using pData. 

This is what helped me to get rid of this error:

In Linux enter your ballgown folder and do ls -ltr | awk '{print$9}' and you will have the right sequence that you have to put inside you .csv file using Notepad++, indicating what's what. Below's my example compared to the above mentioned initial example:

id,state
RNA-CCC_12N_S7_L002,control
RNA-CCC_12T_S8_L002,tube
RNA-CCC_13N_S105_L002,control
RNA-CCC_13T_S106_L002,tube
RNA-CCC_23N_S107_L002,control
RNA-CCC_23T_S108_L002,tube
RNA-CCC_8N_S5_L002,control
RNA-CCC_8T1_S6_L002,tube


I don't have my error anymore and after 

phenodata &lt;- read.csv('my_phenodata_file.csv')
bg = ballgown(dataDir = "ballgown", samplePattern = "RNA-CCC_", pData = phenodata) 


my results are nicely wrapped

Sat May 02 22:11:57 2020
Sat May 02 22:11:57 2020: Reading linking tables
Sat May 02 22:11:59 2020: Reading intron data files
Sat May 02 22:12:04 2020: Merging intron data
Sat May 02 22:12:06 2020: Reading exon data files
Sat May 02 22:12:14 2020: Merging exon data
Sat May 02 22:12:16 2020: Reading transcript data files
Sat May 02 22:12:20 2020: Merging transcript data
Wrapping up the results
Sat May 02 22:12:22 2020


The problem is explained here as well

https://www.biostars.org/p/228389/

Hope this will help anyone