Question
A few years ago my friend from grad school, Craig, moved his successful mouse research lab from Wisconsin to Colorado. He wanted to study the
A few years ago my friend from grad school, Craig, moved his successful mouse research lab from Wisconsin to Colorado. He wanted to study the effects of cannabinoids on mouse physiology and this was at a time when Colorado was leading the nation in relaxing regulations aimed at Cannabis products. One of his preliminary experiments involved feeding what he referred to as a THC cocktail to female mice and recording their weight. In his study the test variable was diet, with two treatment levels: high THC and low THC. The response variable was mass, measured in grams. He measured the mass of each mouse twiceonce at the beginning of the study, and again at the end. He should have summarized these values in his data set by simply indicating the change in mass, but he didnt. He also should have standardized the change in mass for individual mice by converting it to a proportion of starting mass gained or lost. His results are provided in the .csv file available separately in Canvas. Use Craigs data to complete the following tasks using R. As you work, compose all of your R commands in the script pane of R Studio, so that they may be saved as one R file. Be sure to annotate your work in the script pane as you go, using the pound sign (#) to write me notes. This is necessary so that I know which of your commands provides an answer to which of the questions/tasks below. Try to be as helpful and as descriptive as possible with your annotations because they will influence my ability to interpret your work.
1. Begin your R script by providing the usual commands to clear the memory of R and add the R packages ggplot2 and dplyr to the library. Then provide the scripted commandnecessary to import the mouse data set into R. Note that if you want to use readr to input the data, you will need to add the readr package to the library. Clearly annotate all of this with the relevant number (1) so that I can identify your work. Continue appropriate numbering in your annotations as you respond to the numbered steps below.
2. Use a dplyr function to transform Craigs raw data. You want to use dplyr to do what Craig should have done: add a column for the proportional change in mass for each mouse observed. I think of this as a two-step process of subtraction followed by division (I will leave it up to you to figure out what is being subtracted and divided). If it is easier for you to separate the two steps by adding a column for each arithmetic function, thats fine. If you would rather just add one column with the desired transformed variable in it, thats fine too. Whatever you decide, be sure to annotate!
3. Use a ggplot2 function to produce a pair of histograms in two facets that show the distribution of proportional change in mass. One of the histograms should show the distribution for mice fed the high THC diet, and the other histogram should show the distribution for mice fed the low THC diet. Dont forget to annotate.
4. Use a ggplot2 function to produce a box-and-whisker plotthat compares the distribution of proportional mass values for mice fed the high and low THC diets. Label the X-axis Diet type and label the Y-axis Proportional change in mass. Did you annotate?
5. The box plots are nearly perfect, but suppose you want the Y-axis to show percent change in mass. You will need to return to your data frame and add new information using a dplyr function. You want to add a new column to the data frame in which you show percent change in mass (based on proportional change in mass). Once the data frame is modified, make a pair of box plots that depict percent change in mass on the Y-axis, but are otherwise similar to the previous pair. On second thought, since this is your final publication-worthy figure, be sure to use a white background. Annotate, annotate, annotate!
cage_id mouse_id diet mass_start mass_end 1 1 high 24 26 1 2 high 26 27 1 3 high 30 30 2 1 high 24 27 2 2 high 27 30 2 3 high 25 26 3 1 low 34 33 3 2 low 29 29 3 3 low 23 24 4 1 low 25 25 4 2 low 24 25 4 3 low 28 28
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started