bds-files icon indicating copy to clipboard operation
bds-files copied to clipboard

Errata and updates for Chapter 8

Open haruosuz opened this issue 5 years ago • 0 comments


(Page 181)

You access access R’s built-in documentation

should be

You access R’s built-in documentation


(Page 181)

apropos(norm)

printed "Error: is.character(what) is not TRUE", and thus should be

apropos("norm")


(Page 197)

(or use asis;

should be

(or use as.is;


(Page 202)

by dd$start >= 25800000 and dd$end <= 29700000 and

should be

by d$start >= 25800000 and d$end <= 29700000 and


(Page 205)

because d$percent is a vector,

should be

because d$percent.GC is a vector,


(Page 206)

Thus, d[$Pi > 3, ] is identical to d[which(d$Pi > 3), ];

should be

Thus, d[d$Pi > 3, ] is identical to d[which(d$Pi > 3), ];


(Page 208)

gplot2’s grammar through examples.

should be

ggplot2’s grammar through examples.


Page 218

Finding the Right Bin Width

ggplot(d) + geom_bar(aes(x=Pi), binwidth=1) + scale_x_continuous(limits=c(0.01, 80))

printed the following Warning messages:

## Warning: Ignoring unknown parameters: binwidth
## Warning: Removed 3373 rows containing non-finite values (stat_count).

Page 211

—everything is saturated from about 0.05 and below.

should be

—everything is saturated from about 0.005 and below.


(Page 216)

a factor (e.g., d$binned.GC)

should be

a factor (e.g., d$GC.binned)


(Page 217)

Total.SNPs,

should be

total.SNPs,


(Page 219)

try class(d$repClass) and levels(d$repClass)

should be

try class(reps$repClass) and levels(reps$repClass)


Page 222

The pos column is already present in https://raw.githubusercontent.com/vsbuffalo/bds-files/master/chapter-08-r/motif_recombrates.txt

> mtfs <- read.delim("motif_recombrates.txt", header=TRUE, stringsAsFactors=TRUE)
> head(mtfs, 3)
   chr motif_start motif_end    dist recomb_start recomb_end  recom
1 chrX    35471312  35471325 39323.0     35430651   35433340 0.0015
2 chrX    35471312  35471325 36977.0     35433339   35435344 0.0015
3 chrX    35471312  35471325 34797.5     35435343   35437699 0.0015
          motif           pos
1 CCTCCCTGACCAC chrX-35471312
2 CCTCCCTGACCAC chrX-35471312
3 CCTCCCTGACCAC chrX-35471312

(Page 231)

> set.seed(0) # we set the random number seed so this example is reproducible

should be added before

> ll <- list(a=rnorm(6, mean=1), b=rnorm(6, mean=4), c=rnorm(6, mean=6))

Page 232

> lapply(ll, mean) 
$a
[1] 0.5103648
$b
[1] 0.09681026 
$c
[1] -0.2847329

should be

> lapply(ll, mean)
$a
[1] 1.402273

$b
[1] 4.19003

$c
[1] 5.53541

(Page 244)

*My output was
not the order "position GC.binned diversity" as shown in the book
but the order "diversity position GC.binned" as shown below: *

> select(d_df, -(start:cent))
Source: local data frame [59,140 x 3]

   diversity position   GC.binned
       (dbl)    (dbl)      (fctr)
1  0.0000000  55500.5 (51.6,68.5]

because the order of R commands was as follows:

    setwd("~/bds-files/chapter-08-r")
    d <- read.csv("Dataset_S1.txt")
    colnames(d)[12] <- "percent.GC"
    d$cent <- d$start >= 25800000 & d$end <= 29700000
    d$diversity <- d$Pi / (10*1000) # rescale, removing 10x and making per bp
    d$position <- (d$end + d$start) / 2
    d$GC.binned <- cut(d$percent.GC, 5)

(Page 246)

d_df %>% filter(percent.GC > 40) becomes filter(d_df, percent.GC > 40.

should be

d_df %>% filter(percent.GC > 40) becomes filter(d_df, percent.GC > 40).


(Page 249) The Double Backslash

To actually include a black‐ slash in a string,

should be

To actually include a back‐ slash in a string,


(Page 249)

Unlike grep(), regexpr(pattern, x)

should be

Unlike grep(), regexpr(pattern, text)


Page 251

> sub(" *[chrom]+(\\d+|X|Y|M) *", "chr\\1", c("chr19", "chrY"), perl=TRUE)

was changed to

> sub(" *[chrom]+(\\d+|X|Y|M) *", "chr\\1", c("chr19", "chromY"), perl=TRUE)

in Japanese edition. https://www.oreilly.co.jp/books/9784873118635/


Page 255

• RStudio’s Rmarkdown tutorial http://bit.ly/rstudio-rmkdwn

The page doesn't exist. the page may have moved

https://rmarkdown.rstudio.com/


(Page 256)

https://stat.ethz.ch/R-manual/R-devel/library/base/html/args.html Because there is the function args(), variable name of args should be avoided.

## args.R -- a simple script to show command line args
args <- commandArgs(TRUE) print(args)

Page 257

$ ls -l hotspots
[vinceb]% ls -l hotspots

should be

$ ls -l hotspots

(Page 261)

save.history()

should be

savehistory()

I got the following messages:

> savehistory()
Error in .External2(C_savehistory, file) : 
  'savehistory' is not currently implemented

haruosuz avatar Nov 12 '20 12:11 haruosuz