Posts

Showing posts from November, 2025

Assignment #12 - R Markdown

For this week's assignment, we were tasked with learning the basics of R Markdown authoring and document structure by practicing embedding R code, narrative text, and LaTeX math in a single file. Here are some of the things I learned:  While building this document, I learned that Markdown has specific syntax to follow. Including "##" will generate a small header, and any text written without that will display in a paragraph font. To create a code chunk, you have to encase it in ``` ```, and include {r chunk_name}. If you want to hide the code in the rendered output, you would write it as {r chunk_name, include=FALSE}. The code chunk generated with the document (shown below) essentially creates a rule that the R code will be displayed in each chunk by default after knitting.  LaTeX math has two modes, inline or display. The inline equation mode uses a single $ on each end of the equation (e.g., $a^2 + b^2 = c^2$), whereas the displayed mode uses two $$ on each end (e....

Assignment #11 - Debugging and Defense programming in R

Image
This week, we learned about debugging and defensive programming in R. We were provided with the code below and asked to test it on a matrix to determine if any issues arose when running it.  The initial error code that RStudio displayed was: Error in tukey_multiple(test_mat) :    could not find function "tukey_multiple" When running the test matrix below, I discovered two bugs in the code. set.seed(123) test_mat <- matrix(rnorm(50), nrow = 10) tukey_multiple(test_mat) The first issue was that tukey.outlier( ), had not yet been defined. I first defined that function using these lines to ensure that R knew what functions I was trying to call.  tukey.outlier <- function(x) {   q <- quantile(x, c(0.25, 0.75))   H <- 1.5 * IQR(x)   x < (q[1] - H) | x > (q[2] + H) } The second issue, came from the use of && in this line " outliers[, j] <- outliers[, j] && tukey.outlier(x[, j])". The issue with this is that it is scalar lo...

Assignment #10 - Building your own R package

This week, our objectives were: - Learn the structure of an R package and the role of the DESCRIPTION file - Practice writing machine-readable metadata (authors, dependencies, versioning) - Draft a coherent package proposal for your final project - Publish your package scaffold proposal online (GitHub and blog) My R package: disordR Purpose and scope of the project The disordR package is a small toolkit designed to be used for students or researchers studying intrinsically disordered proteins (IDPs). It has a simple pipeline that can be used in class projects or advanced research. First, it will calculate charge-hydropathy metrics (based on the Uversky plot). It will then create a concise output of disorder predictors, and finally, it will map AlphaFold pLDDT to assumed intrinsically disordered regions (IDRs).  Key functions I plan to implement aa_props() - mean hydropathy, net charge, and fraction of charged residues uversky_metrics() - hydropathy and charge per residue; classi...