1

I'm using a beginner's manual (https://apps.dtic.mil/dtic/tr/fulltext/u2/1079243.pdf) in order to count cells from a microscope image using Rstudio. After installing the BiocManager and EBImage package, the manual recommends:

Install.packages("tiff")
Install.packages("pixmap")
Install.packages("rtiff")

However, the 'rtiff' package is not available for the new version of R 4.0.3 (2020-10-10). So I couldn't install it:

Warning in install.packages :
  package ‘rtiff’ is not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages

The manual continues loading the packages, creating the appropriate file paths and directories for the dataset:

library("tiff")
library("pixmap")
library("rtiff")

map_path <- "C:/Cellcounting/Analysis/Images/"
map_savdir <- "C:/Cellcounting/Analysis/Mapped_image"
map_files <- list.files(map_path, pattern="tif", full.name=F)
image_path <- "C:/Cellcounting/Analysis/Mapped_image/"
image_savdir <- "C:/Cellcounting/Analysis/Image_analysis"
image_files <- list.files(image_path, pattern="tiff", full.name=F)
csv_path <- "C:/Cellcounting/Analysis/Image_matrices"

Then, I should create the following for loop to convert images into pixel maps:

 for (i in 1: length (map_files)) {
  mapped_image <- paste0 (sub (". tif", replacement = "", x = map_files [i]), "_ mapped.tiff")
  map1 <- readTiff (paste0 (map_path, map_files [i]))
  map2 <- as.matrix (map1 @ red)
  map2 [map2 <0.3] <- 0
  writeTiff (map2, paste0 (map_savdir, "/", mapped_image))
 }

At this point I get the following error, which I assume is because I was unable to install the 'rtiff' package:

Error in readTiff (paste0 (map_path, map_files [i])):
  could not find function "readTiff"

What I can do? Is there an alternative to rtiff?

Thanks in advance,

Phil
  • 7,287
  • 3
  • 36
  • 66
Jesus ML
  • 11
  • 1

1 Answers1

0

I'm having the same issues. I'm using this program in order to similar cell counts within R and cannot get 'rtiff' to install correctly.

'rtiff' is no longer in CRAN, so I've been trying to install 'rtiff' from CRAN's archive using the following code:

install.packages("devtools")
library(devtools)
install_github("cran/rtiff")

as well as:

packageurl<-"https://cran.r- 
project.org/src/contrib/Archive/rtiff/rtiff_1.4.tar.gz"
install.packages(packageurl,repos=NULL,type="source",dependencies = T)

I get the same error that the install of the package had a non-zero exit status. I've continued scouring the internet and various forms to try to get the full package to install.

The one thing that I've come close to is importing the functions 'readTiff' and 'writeTiff' into the R environment by downloading the tar.gz file from the CRAN archive, unzipping the contents using WinZIP, and placing it into your repository. Here's the example code:

setwd('C:/Users/Computer/Documents/rtiff_1.4.8/rtiff/R')
source('readTiff.R')
source('writeTiff.R')

This gave me the ability to have these functions within the R environment, but alas, more errors began to pop-up when trying to run the for-loop to create mapped images:

Error in .C("C_TiffGetWidth", as.character(fn), w = as.integer(w), PACKAGE = "rtiff") : 
"C_TiffGetWidth" not available for .C() for package "rtiff"

I'm continuing to look more into this. I actually work with one of the authors of this manual that you're referencing so hopefully we can fix this and update you asap.