-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
Data visualizationRanything related to R programming languageanything related to R programming languagebugSomething isn't workingSomething isn't working
Description
#set directory
setwd("C:/Users/larke/OneDrive/Desktop/R/R")
#step 1 - import the cilia text file
#import text file #tabs delimited
my_data <- read.csv("pixel intensity data tab.txt", header = TRUE, sep='\t')
#testing data class
class(my_data)
#renames columns
names(my_data)[1]<-"Frame"
names(my_data)[2]<-"Mean1"
#step 2 - fourier transform of the values
#will use fft (fast fourier transform)
#will first test fft on one column
Mean1four = fft(my_data$Mean1)
#now do the fft on whole dataframe
fourierd = apply(my_data,2,function(x) fft(as.numeric(x))) #it's now a matrix
#turn it into a data frame
fourierdat = as.data.frame(fourierd)
#fix frame numbers (they were also fft-ed)
fourierdat$Frame = seq(1:256)
#Error in `$<-.data.frame`(`*tmp*`, Frame, value = 1:512) :
# replacement has 512 rows, data has 256
# Therefore IL canged "(1:512)" to "(1:256)
#step 3 - get the absolute value of the complex numbers resulting from the fft
#in excel this is done using =IMABS(range)
absTest = abs(fourierdat$Mean1) #testing on one column
absTestAll = abs(fourierdat) #converts all the complex numbers to absolute numbers
#step 4 - calculating the CBF
#if frequency resolution is = 0.94
#if is not 0.94, replace with correct value
FRadjusted = absTestAll$Frame*0.94
absTestAll$Frame = FRadjusted #this updates the frame to 0.94
#Pre-defining the matrix
HisDat <- 1
# For each column of data, find the max number & corrisponding row number.
# multiply the two new values together -> HisDat (Histogram Data)
for(i in 1:lengths(absTestAll)){
MaxNum <- max(absTestAll[[i]]);
MaxRow <- which(grepl(max(absTestAll[[i]]), absTestAll[[i]]))
HisDat[i] <- MaxNum*MaxRow
}
# Plot the Histogram
hist(HisDat,
breaks=256)
# multiply max ab no. by row number and frequency resolution
# to result in 1600 data points which = CBF in 1600 areas of interest
|
#Playing with my histogram
histinfo <- hist(HisDat)
#step 5 - CBF HistogramReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Data visualizationRanything related to R programming languageanything related to R programming languagebugSomething isn't workingSomething isn't working