Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi! I cleaned up your code for you! #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.pyc

# Logs and databases #
######################
*.log

# OS generated files #
######################
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db
2 changes: 1 addition & 1 deletion pca_me.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ if (num_cases==0)
end <- samples_in_test + count
for (j in start:end)
{
color[j:j, 1] <- as.character(samples[i:i, 2])
color[j:j, 1] <- as.character(samples[i:i, 2])
}
start <- end + 1
count <- count + samples_in_test
Expand Down
16 changes: 8 additions & 8 deletions poisson.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# get from input
# get from input
data <- commandArgs(trailingOnly=TRUE)[1] # get the file name with the counts
mode <- commandArgs(trailingOnly=TRUE)[2] # do you want to use the raw counts or the percent of total reads? pertotal or count
num_reads <- commandArgs(trailingOnly=TRUE)[3] # file with the number of reads
Expand All @@ -10,16 +10,16 @@ data <- read.delim(data, header=T, sep="\t", row.names=1)
names <- row.names(data)
attach(data)

# define some variables
# define some variables
row <- length(data[,1]) # number of functions or OTUs
col <- length(data[1,]) # number of samples
pvalc <- col + 2
qvalc <- col + 3
treatment <- gl(2,4,col) # which samples are cases and controls ?
treatment <- gl(2,4,col) # which samples are cases and controls ?
outcome <- gl(4,1,col) # which samples are paired ?

# make matricies
counts <- matrix(0, nrow=row, ncol=col)
# make matricies
counts <- matrix(0, nrow=row, ncol=col)
pvalue <- array(0, dim=row)
pertotal <- matrix(0, nrow=row, ncol=col)
qvalue <- matrix(0, nrow=row, ncol=1)
Expand All @@ -31,16 +31,16 @@ if (mode=="pertotal")
for (i in 1:row)
{
for (j in 1:col)
{
{
pertotal[i:i, j:j] <- (data[i:i, j:j]/num_reads[j:j, 1])*100
}
}
}
data <- pertotal
}

# poisson!
for (i in 1: row)
{
{
counts[i,] <- t(data[i,])
model <- glmer(counts[i,] ~ treatment +(0+treatment|outcome),family=poisson())
pvalue[i] <- summary(model)@coefs[2,4]
Expand Down
26 changes: 13 additions & 13 deletions standardizeR.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if (method==0)
for (i in 1:row)
{
for (j in 1:col)
{
{
pertotal[i:i, j:j] <- ((data[i:i, j:j])/(reads[j,1]))*100
#pertotal_adj[i:i, j:j] <- pertotal[i:i, j:j]*1000000
#trans[i:i, j:j] <- log(pertotal_adj[i:i, j:j]+1, 2)
Expand All @@ -57,7 +57,7 @@ if (method==1)
for (i in 1:row)
{
for (j in 1:col)
{
{
pertotal[i:i, j:j] <- ((data[i:i, j:j])/(reads[j,1]))*100
trans[i:i, j:j] <- log(pertotal[i:i, j:j]+1, 10)
sdev_case[i,1] <- sd(trans[i:i, 1:num_cases])
Expand All @@ -74,7 +74,7 @@ if (method==2)
for (i in 1:row)
{
for (j in 1:col)
{
{
pertotal[i:i, j:j] <- ((data[i:i, j:j])/(reads[j,1]))*100
trans[i:i, j:j] <- log(pertotal[i:i, j:j]+1, 10)
sdev[i,1] <- sd(trans[i:i, 1:col])
Expand All @@ -83,27 +83,27 @@ if (method==2)
}
}

## method 3: Log transform the raw counts. Calculate standard deviation and average for cases and controls, separately, across columns.
## method 3: Log transform the raw counts. Calculate standard deviation and average for cases and controls, separately, across columns.
if (method==3)
{
for (i in 1:row)
{
for (j in 1:col)
{
{
trans[i:i, j:j] <- log(data[i:i, j:j]+1, 2)
sdev[1, j:j] <- sd(trans[1:row, j:j])
average[1, j:j] <- mean(trans[1:row, j:j])
}
}
}

## method 4: Log transform the raw counts. Calculate standard deviation and average for cases and controls, together, across rows.
## method 4: Log transform the raw counts. Calculate standard deviation and average for cases and controls, together, across rows.
if (method==4)
{
for (i in 1:row)
{
for (j in 1:col)
{
{
trans[i:i, j:j] <- log(data[i:i, j:j]+1, 10)
sdev[i,1] <- sd(trans[i:i, 1:col])
average[i,1] <- mean(trans[i:i, 1:col])
Expand All @@ -117,7 +117,7 @@ if (method==5)
for (i in 1:row)
{
for (j in 1:col)
{
{
pertotal[i:i, j:j] <- ((data[i:i, j:j])/(reads[j,1]))*100
}
}
Expand Down Expand Up @@ -198,7 +198,7 @@ if (method==5)
stand <- pertotal
}

#multiple sample scaling
#multiple sample scaling
if (mss=="true")
{
allstand <- matrix(0, nrow=row*col, ncol=1)
Expand Down Expand Up @@ -254,7 +254,7 @@ if (ttest=="notpaired")
# if doing a ttest
if (ttest!="none")
{
#make more matricies
#make more matricies
qvalues <- matrix(0, nrow=row, ncol=1)
qval <- qvalue(ttest[,1])$qvalues
qvalues <- as.matrix(qval)
Expand All @@ -268,7 +268,7 @@ if (ttest!="none")
table[, qvalc] <- qvalues
print <- data.frame(table, row.names=annotations)
print <- print[order(print[,ttestc], print[,qvalc]),]

#plot some data
boxplot(data, main="raw counts")
boxplot(pertotal, main="raw percent of total reads")
Expand All @@ -288,12 +288,12 @@ if (ttest!="none")

#if not doing a ttest
if (ttest=="none")
{
{
#make the table
table <- matrix(0, nrow=row, ncol=col)
table[,1:col] <- as.matrix(stand)
print <- data.frame(table, row.names=annotations)

#plot some data
boxplot(data, main="raw counts")
boxplot(pertotal, main="raw percent of total reads")
Expand Down