Reading Files

Author

Kaitlin Sullivan

⟵ Previous: CSV File Formatting Next: The mFISH Object ⟶

Video Tutorial

In this video, we go over how to use ruRead() to take our multiple gene CSVs output from FijiFISH and amalgamate them into a single data frame.

See the code below to follow along with the analyses.

Reading files with ruRead()

We will use ruRead() to read all of the gene expression FIJI Quantification files into a single data frame.

The primary argument is the path to the folder holding all of the gene CSVs from FijiFISH. You must also fill out at least three metadata variables for image identification during plotting and analysis down the line.

####### STEP 1a: READING FILES FROM FIJI QUANTIFICATION #########
#here we are using an example dataset from our 2021 eLife paper - https://elifesciences.org/articles/68967

#the data is deposited both within this repository as well as on FigShare, but it is preferable to use your own files generated from FijiFISH!

mydata <- ruRead("data", region = "cla", anum = "123456", section = "1")
[1] "The following files will be quantified:"
 [1] "R1_488_Nnat.tif_registered.tif_NL.tif_quantification.csv"   
 [2] "R1_550_Synpr.tif_registered.tif_NL.tif_quantification.csv"  
 [3] "R1_647_Pcp4.tif_registered.tif_NL.tif_quantification.csv"   
 [4] "R1_750_Slc17a7.tif_registered.tif_NL.tif_quantification.csv"
 [5] "R2_488_Cdh9.tif_registered.tif_NL.tif_quantification.csv"   
 [6] "R2_550_Ctgf.tif_registered.tif_NL.tif_quantification.csv"   
 [7] "R2_647_Slc17a6.tif_registered.tif_NL.tif_quantification.csv"
 [8] "R2_750_Lxn.tif_registered.tif_NL.tif_quantification.csv"    
 [9] "R3_488_Slc30a3.tif_registered.tif_NL.tif_quantification.csv"
[10] "R3_550_Gfra1.tif_registered.tif_NL.tif_quantification.csv"  
[11] "R3_647_Spon1.tif_registered.tif_NL.tif_quantification.csv"  
[12] "R3_750_Gnb4.tif_registered.tif_NL.tif_quantification.csv"   
[13] "R4_488_RSC.tif_registered.tif_NL.tif_quantification.csv"    
[14] "R4_545_LEC.tif_registered.tif_NL.tif_quantification.csv"    
#make sure all your genes are names correctly before continuing
#you should have columns named X,Y,id,region,section,anum and all of your genes
head(mydata)
        X      Y      Nnat      Synpr      Pcp4    Slc17a7      Cdh9      Ctgf
1 134.920 33.948 0.1834896  0.0000000 5.5177946  0.0000000 0.7358308 0.3679154
2 167.766 32.075 0.0000000  0.0000000 0.0000000  0.0000000 2.1668655 0.0000000
3 233.271 35.724 0.0000000  0.0000000 0.0000000  0.6694704 0.0000000 0.0000000
4 279.353 34.970 0.0000000  0.2438931 0.4888655 13.1972094 0.2438931 0.4888655
5 363.526 37.364 0.1613582  0.2426580 0.8893321 38.7961045 0.3233371 0.3233371
6 412.295 32.073 0.0000000 12.5748426 0.0000000 23.0532699 0.0000000 0.0000000
     Slc17a6 Lxn   Slc30a3     Gfra1     Spon1      Gnb4 RSC LEC region   anum
1 0.73583077   0 0.0000000 0.0000000 1.1037462 0.0000000   0   0    cla 123456
2 2.16686552   0 0.7216701 0.0000000 0.0000000 0.0000000   0   0    cla 123456
3 1.00420555   0 0.0000000 0.3347352 0.6694704 0.6694704   0   0    cla 123456
4 0.73275862   0 0.0000000 0.0000000 0.0000000 0.0000000   0   0    cla 123456
5 0.08067912   0 0.4040162 0.0000000 3.1520710 2.0207016   0   0    cla 123456
6 0.00000000   0 0.0000000 1.3976102 0.0000000 0.0000000   0   0    cla 123456
  section id
1       1  1
2       1  2
3       1  3
4       1  4
5       1  5
6       1  6
#feel free to add extra metadata for your section at this point with dplyr::mutate()

In the plausible case where we have multiple images that we want to analyze together, we will use ruCombine() to concatenate multiple data frames from separate experiments.

Ensure that the analyzed tables from each experiment are in their own separate folders. Then generate a data frame for each using ruRead(). Finally, concatenate them together using ruCombine().

IMPORTANT: Ensure you have unique section ids for each image in the metadata so you can properly separate each image from another in the downstream analysis

####### STEP 1b: COMBINING MULTIPLE SECTIONS #######
#if you have multiple sections you can save multiple experiments as a data.frame using ruRead()
#to combine them use: 

combo <- ruCombine(c(data1, data2, data3))

⟵ Previous: CSV File Formatting Next: The mFISH Object ⟶