R Course FAQs
- Where can I find examples of different types of plots?
The R Graph Gallery is a fantastic resource for R data visualization. The gallery can be used to explore different plot types and the code used to generate those plots. A similar resource, from Data to Viz uses decision trees to guide you to the plot type that best works with your data.
- Will we get the opportunity to work with our own data in BTEP R courses?
Absolutely, all of our R courses have corresponding help sessions in which you can work with your data and ask us questions as they arise.
- Can we attend BTEP R course help sessions to seek help for R projects / questions unrelated to the current lesson?
Yes, we are happy to help you troubleshoot any R problem. However, depending on the question, we may need more time to adequately address your concerns, especially if you are using a specific R package.
- Will there be more R training courses?
We will be offering multiple R course series and other bioinformatic courses. Check the BTEP calendar for a list of upcoming events.
- Where can we get more help on the R syntax?
Dataquest is an excellent resource to learn more regarding R syntax. Dataquest licenses are available to intramural NCI CCR personnel. See instructions for obtaining a license here.
- How can I use DNAnexus outside of class to practice R?
DNAnexus is available to practice outside of class while a course is in session, for course registrants only. For each course, we will supply course specific instructions for accessing DNAnexus outside of class. Often these instructions are available within the course materials. For a more longterm solution, you should install R / RStudio locally (on your laptop or desktop computer).
- If I want to label one data point in a PCA or volcano plot, how would I go about doing that?
There multiple ways to label individual points in a plot. Here is one such example using the data set iris
.
The basic steps are:
Step 1 - filter data frame with points we want to label
Step 2 - add labels using geom_text and call filtered data set
ggrepel
is a great package to use if you want to avoid labels overlapping.
#run pca
pca <- prcomp(iris[,1:4], scale = TRUE)
#Build a data frame to plot
pcaData <- as.data.frame(pca$x[, 1:2]) # extract first two PCs
pcaData <- cbind(pcaData, iris) # add data
pcaData <- rownames_to_column(pcaData,"ID") #add ID column
#create a filtered data frame with points we want to label
fdata<-pcaData %>%
filter(ID %in% c(1,5,10))
#Plot
ggplot(pcaData) +
aes(PC1, PC2, color = Species, shape = Species) + # define plot area
geom_point(size = 2) + # adding data points
coord_fixed() + # fixing coordinates
geom_text(data=fdata,
aes(x = PC1, y = PC2,label=ID),color="black") # label points
- What are the ideal dimensions and recommendations for exporting visuals?
The ideal dimenstions and resolution of a figure will depend on how you are using it. Most scientific journals have their own requirements. If you need to effectively scale your image, here are some recommendations.