In this vignette, we will retrieve fluorescence intensity values around the position of each spot and display the mean intensity for each spot.

Loading Data

To get the correspondence between spots positions and pixels indices in the .h5 file, we need the .xml file generated by the Big Data Viewer (that was loaded the first time in the Fiji MaMut plugin to start the annotations).

fileXML <- xmlToList(system.file("extdata", "MaMuT_Parhyale_demo-mamut.xml", package = "mamut2r"))
fileXML_BDV <- xmlToList(system.file("extdata", "MaMuT_Parhyale_demo.xml", package = "mamut2r"))

Importing spots and tracks

We import the spots and tracks.

Calculate x, y, z coordinates from registration (setup 0 in Big Data Viewer file)

We now extract information relative to the View registration stored in the BIg Data Viewer file. According to the supplemental information from the Big Data Viewer paper (Pietzsch et al. 2015, Nature methods, Vol.12 No.6), “ […] describe the transformations that register each view’s raw voxel coordinates into the global coordinate system.”

read_ViewRegistration() collect all the affine transformations for all timepoints and only setup 0.

prod_affine_registration() concatenate all affine transforms from a given timepoint together.

The lines below apply the affine transform of the corresponding timepoint on each spot coordinates and return a new set of coordinates (POSITION_X_loc, POSITION_Y_loc, POSITION_Z_loc).

Spots_df_loc <- Spots_df %>%
  left_join(Registration_df2, by = c("FRAME" = "Timepoint")) %>%
  rowwise() %>%
  mutate(pos_local = list({#browser();
    res <- crossprod(prod_affine_inv,
              c(POSITION_X, POSITION_Y, POSITION_Z, 1))[1:3,]
      tibble(POSITION_X_loc = res[1],
                 POSITION_Y_loc = res[2],
                 POSITION_Z_loc = res[3])
  })) %>%
  unnest(pos_local, .drop = FALSE)

With the code below you can visually quickly check the positions of the spots before and after applying the affine transforms.

Plot distribution of fluorescence per nuclei

We can now display the output of getFluo(). Let’s first select one timepoint only.

The Parhyale dataset has 10 timepoints. The fluorescent data are stored in a list (here called all_cells), of 10 elements (one per timepoints), each of these containing as many elements as the number of spots in the timepoint. In these elements are stored the fluorescence intensities of all the pixels in a cube of 10x10x10 pixels (if using the default cubeSize) around the spot location. Let’s have a look at the distribution of fluorescence of spots at the 6th timepoint, i.e. all_cells[[5]].

Calculate the mean and median fluorescent value for each spot

mmFluo() calculate the mean and median fluorescent value for each spot.

You can visualise the distribution of the mean fluorescent values over the whole movie using {ggplot2}.

You can also separate the data per timepoint using the facet wrap from {ggplot2} or the geom_density_ridges from {ggridges}:


ggplot(Spots_df, aes(x = meanFluo, y = frame, fill = frame)) +
  geom_density_ridges() +
  theme_ridges() + 
  theme(legend.position = "none")
#> Picking joint bandwidth of 123

Send back color to MaMuT .xml file

Continuous numerical variables added to Spots_df, like for instance the mean fluorescence intensity value for each spot, can be converted to colors and then converted to integer readable by the MaMuT Fiji plugin and added as a “MANUAL_COLOR” field.

These new “MANUAL_COLOR” field can be added to the MaMuT .xml file. The “MANUAL_COLOR” field is already defined in the features of the MaMuT .xml file. Other new fields are not supported yet by the modifyXML(), as this function does not add new features to define new fields. Below is an example of how to modify the MaMuT .xml file.

Visualise the fluorescence value in 3D

We can visualise the fluorescence intensity values in 3D using the plotlySpots() function from {cellviz3d}, based mainly on the {plotly} library.

We can also visualise all the timepoints together, using the plotlySpots_all() function from {cellviz3d}, also mainly based on {plotly}.

To go further: normalisation of fluorescence accross the whole movie - different possibilities

  1. take the fluo of vasculature nuclei as a reference (check first that they do not change too much over time)
  1. normalise to mean/median of all nuclei of the whole movie
Spots_df <- mmFluo_wholeMovie(Spots_df, all_cells)
  1. normalise to mean/median of all nuclei of the current frame
  1. look at variations of the fluorescence intensity by spot over time

To calculate a mean and median fluorescence value per spot + calculate normalised fluorescence accross the whole movie, or for the current frame, all in one go, you can use the mmFluo_all() function.

Additionnal example: adding a spot in the background to compare fluorescence of background and nuclei

We created an other mamut .xml file named “MaMuT_Parhyale_demo-mamut_withSpotOutside.xml” with one track outside the Parhyale nuclei. The spots in Track ID 42 are located on the background. They have the ID 3964, 3963, 3937, 3965, 3968, 3966, 3962, 3967, and 3961.

fileXML_out <- xmlToList(system.file("extdata", "MaMuT_Parhyale_demo-mamut_withSpotOutside.xml", package = "mamut2r"))

We import the spots with Spots.as.dataframe().

We calculate the position of the spots using the registration found above.

We retrieve the fluorescence in a cube of 10x10x10 pixels around each nucleus.

We calculate the mean and median fluorescence values for all spots.

We now display the spots using plotlySpots_all(). When mousing over the spots, we see that the fluorescence values of the spots with the IDs 3964, 3963, 3937, 3965, 3968, 3966, 3962, 3967, and 3961 are very low compared to the fluorescence values of the other spots.