Skip to content

Commit

Permalink
added figure01 qmd
Browse files Browse the repository at this point in the history
  • Loading branch information
tractatus committed Sep 18, 2023
1 parent f22f1c8 commit a736903
Show file tree
Hide file tree
Showing 16 changed files with 3,796 additions and 1 deletion.
478 changes: 478 additions & 0 deletions figure01.html

Large diffs are not rendered by default.

151 changes: 151 additions & 0 deletions figure01.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# figure01

- [Emission plot](#emission-plot)

## Emission plot

``` r
files<-dir('data/spectra/emission', full.names = TRUE)

spectra<-read.table(files[1], sep='\t')
spectra$sample <- 1

for(i in seq_along(files)[-1]){
spectra.tmp <-read.table(files[i], sep='\t')
spectra.tmp$sample <- i
spectra <- rbind(spectra, spectra.tmp)
}

spectra$fluor <- NA

spectra$fluor[spectra$sample %in% seq(9,17)] <- 594
spectra$fluor[!(spectra$sample %in% seq(9,17))] <- 488

spectra$status <- NA

status<-c('fluor', 'quench', 'fluor',
'quench', 'quench', 'unquench',
'unquench', 'unquench', 'unquench',
'fluor', 'fluor', 'fluor',
'quench', 'quench', 'quench',
'unquench', 'unquench', 'unquench')
k<-1
for(i in unique(spectra$sample)){


spectra$status[spectra$sample==i]<-status[i]

}


library(dplyr)
```


Attaching package: 'dplyr'

The following objects are masked from 'package:stats':

filter, lag

The following objects are masked from 'package:base':

intersect, setdiff, setequal, union

``` r
spec<- spectra %>%
group_by(fluor, status, V3) %>%
summarise(emission=mean(V4))
```

`summarise()` has grouped output by 'fluor', 'status'. You can override using
the `.groups` argument.

``` r
spec$emission[spec$fluor == 488]<-spec$emission[spec$fluor == 488]/max(spec$emission[spec$fluor == 488 & spec$status == 'fluor'])
spec$emission[spec$fluor == 594]<-spec$emission[spec$fluor == 594]/max(spec$emission[spec$fluor == 594 & spec$status == 'fluor'])

spec$emission <- spec$emission - mean(spec$emission[1:50])


col2hex <- function(cname)
{
colMat <- col2rgb(cname)
rgb(
red=colMat[1,]/255,
green=colMat[2,]/255,
blue=colMat[3,]/255
)
}

spec<- spec[-which(spec$status == 'unquench'),]

quartz(width = 130.1729/20, height = 83.8626/20)
par(yaxs='i', xaxs='i', mar=c(4,4,1,1))
plot(0,0, type='n', xlim=c(450,750), ylim=c(0,1), ylab='Emission', xlab="Wavelength (nm)", las=1, axes=F)
axis(2, las=1, at=c(0,0.5,1))

color <- c('green3', 'green4', 'red', 'red4')
unique_samples <- unique( paste(spec$fluor, spec$status) )
names(spec)<-c("fluor" , "status" , "wavelength" , "emission")

peak.max <- numeric()
# Loop through each unique sample and create a polygon plot
for (sample_name in unique_samples) {
# Subset the data for the current sample
sample_data <- spec[paste(spec$fluor, spec$status) == sample_name, ]

# Create a polygon plot for the current sample
polygon(c(sample_data$wavelength,
sample_data$wavelength[nrow(sample_data)],
sample_data$wavelength[1],
sample_data$wavelength[1]),

c(sample_data$emission, 0, 0, sample_data$emission[1]),
col = paste0( col2hex( color[match(sample_name, unique_samples)] ), '70' ),
border = color[match(sample_name, unique_samples)], lwd=2, xpd=F )

# Add a legend for sample names
legend("topright", legend = unique_samples, fill = color)

peak.max <- c(peak.max, sample_data$wavelength[which.max(sample_data$emission)] )
}

axis(1, at=seq(300,800,by=50))
```

![](figure01_files/figure-commonmark/unnamed-chunk-1-1.png)

Save the plot.

``` r
quartz.save(file="pdf/figure01_c.pdf", type='pdf')
```

quartz_off_screen
2

Then compute quench ratio:

``` r
quench.ratio <- spec %>% group_by(fluor, status) %>% summarise(max(emission))
```

`summarise()` has grouped output by 'fluor'. You can override using the
`.groups` argument.

``` r
AZdye488<-quench.ratio$`max(emission)`[1]/quench.ratio$`max(emission)`[2]

AZdye594<-quench.ratio$`max(emission)`[3]/quench.ratio$`max(emission)`[4]

round(AZdye488, 2)
```

[1] 5.74

``` r
round(AZdye594, 2)
```

[1] 2.88
3 changes: 2 additions & 1 deletion figure01.qmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: "figure01"
format: html
format: gfm
toc: true
---

## Emission plot
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figure01_files/figure-html/unnamed-chunk-1-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a736903

Please sign in to comment.