> chrs = levels(RT$CHR); str(chrs)
|
# Create a list of all chromosomes
|
> AllLoess = NULL
|
# Initialize a variable to store all loess-smoothed data
|
> for (chr in chrs) {
|
# For each chromosome,
|
> RTl = NULL
|
# Create a variable to store loess-smoothed values
|
> RTb = subset(RT, RT$CHR == chr)
|
# Subset the dataset to a single chromosome
|
> lspan = 300000/(max(RTb$POSITION)-min(RTb$POSITION))
|
# Set smoothing span
|
> cat(“Current chromosome: “, chr, “\n”)
|
# Output current chromosome to console
|
> RTla = loess(RTb$ mLymphR1~ RTb$POSITION, span = lspan)
|
# Smooth dataset 1
|
> RTlb = loess(RTb$mLymphR2~ RTb$POSITION, span = lspan)
|
# Smooth dataset 2
|
> RTlc = loess(RTb$mLymphAve ~ RTb$POSITION, span = lspan)
|
# Smooth dataset 3
|
> RTl = data.frame(CHR=RTb$CHR, POSITION=RTb$POSITION, RTla$fitted, RTlb$fitted,
|
# Combine the datasets for the current chromosome
|
> AllLoess = rbind(AllLoess, RTl)
|
# Combine current chromosome with overall dataset
|
> }
|
# End for loop
|
> x = as.data.frame(AllLoess)
|
# Reformat the smoothed datasets as a data frame
|