Skip to content

Lesson 3 Exercise Questions: BaseR dataframe manipulation and factors

The filtlowabund_scaledcounts_airways.txt includes normalized and non-normalized transcript count data from an RNAseq experiment. You can read more about the experiment here.

We are going to use the filtlowabund_scaledcounts_airways.txt file for this exericise. Get the data here.

Putting what we have learned to the test:
The following questions synthesize several of the skills you have learned thus far. It may not be immediately apparent how you would go about answering these questions. Remember, the R community is expansive, and there are a number of ways to get help including but not limited to google search. These questions have multiple solutions, but you should try to stick to the tools you have learned to use thus far.

  1. Import the filtlowabund_scaledcounts_airways.txt into R and save to an R object named transcript_counts. Try not to use the dropdown menu for loading the data.

    Solution

    transcript_counts <-read.delim("./data/filtlowabund_scaledcounts_airways.txt")
    

  2. What are the dimensions of transcript_counts?

    Solution

    dim(transcript_counts)
    

  3. What are the column names?

    Solution

    colnames(transcript_counts)
    

  4. How many categories of transcripts are there? Think about what you know regarding factors.

    Solution

    nlevels(factor(transcript_counts$transcript,exclude=NULL))
    

  5. Rename the column "sample" in transcript_counts to "SampleID".

    Solution

    colnames(transcript_counts)[2]<-"SampleID"
    

  6. What is the mean and standard deviation of "avgLength" across the entire transcript_counts data frame? Hint: Read the help documentation for mean() and sd().

    Solution

    mean_avgLength<- mean(transcript_counts$avgLength)
    sd_avgLength<- sd(transcript_counts$avgLength)
    

  7. Make a data frame with the column names "Mean" and "Standard_Dev" that holds the values from question 6. Hint: check out the function data.frame().

    Solution

    data.frame(Mean=mean_avgLength, Standard_Dev=sd_avgLength)