Skip to content

Instantly share code, notes, and snippets.

@tractatus
Last active November 26, 2018 03:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tractatus/9a4fec16db6a91ccdeb361c507f2c884 to your computer and use it in GitHub Desktop.
Save tractatus/9a4fec16db6a91ccdeb361c507f2c884 to your computer and use it in GitHub Desktop.
################################
# (c) Daniel Fürth, 2016
# Spatial Transcriptomics with WholeBrain
################################
#set the anterior poster coordinate of brin section in millimeter
coordinate.for.section<- -0.42
#set filter for Cy3 spots
feature.filter <-structure(list(alim = c(120, 1000), threshold.range = c(14L, 255
), eccentricity = 1000L, Max = 70, Min = 0, brain.threshold = 1L,
resize = 0.08*0.25, blur = 4L, downsample = 0.125/2), .Names = c("alim",
"threshold.range", "eccentricity", "Max", "Min", "brain.threshold",
"resize", "blur", "downsample"))
#set filter for H&E nuclei and the background of the brain section
cell.body.filter <-structure(list(alim = c(3, 50), threshold.range = c(140L,
255L), eccentricity = 1000L, Max = 200, Min = 10, brain.threshold = 50L,
resize = 0.08*0.20, blur = 4L, downsample = 0.25), .Names = c("alim",
"threshold.range", "eccentricity", "Max", "Min", "brain.threshold",
"resize", "blur", "downsample"))
#file paths
HandE.file<-'~/Downloads/160919_SE2_St&Th_ID3_E1_H&E_AJu.jpg'
Cy3.file<-'~/Downloads/161006_SE2_St&Th_ID3_E1_Cy3_AJu.jpg'
temp<-spatial.transcriptomics(HandE.file, Cy3.file, feature.filter, cell.body.feature)
#registration
regi<-registration(temp$filename, coordinate= coordinate.for.section, filter=cell.body.filter, right.hemisphere=FALSE)
#EDIT the registration:
regi <-remove.corrpoints(regi, 1:32) #remove all 32 corrpoints and overwrite original registration
regi<-add.corrpoints(regi, 32) #manually add 32 unique corrpoints both in Target (right, purple) and in Reference (orange, left)
#regi<-change.corrpoints(regi, c(13,14,16)) #if I just want to change corrpoint 13 and 14 and 16 in the Target image
#rerun the registration with the new corrpoints by adding correspondance=regi
regi<-registration(temp$filename, coordinate= coordinate.for.section, filter=cell.body.filter, right.hemisphere=FALSE, correspondance=regi)
#get the data set
dataset<-inspect.registration(regi, temp$features, forward.warps=TRUE, draw.trans.grid=FALSE)
head(dataset)
dataset$animal<-'ID3_E1'
#plot the section
schematic.plot(dataset)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment