katholt / srst2

Short Read Sequence Typing for Bacterial Pathogens
Other
125 stars 65 forks source link

Rcode #33

Closed paolaflorez closed 9 years ago

paolaflorez commented 9 years ago

Hello Kat,

I love SRST2, but I would like to plot out the results the readme file says "Added R code for plotting SRST2 output in R (plotSRST2data.R). Instructions will be added to the read me." When!! Is it ready? I was hoping to present it at lab meeting this Thursday. Is there any chance?!?

Please and thanks, Paola

paolaflorez commented 9 years ago

Hello Kat,

I found the instructions under your scripts. However I am stuck at the starting block. I have the all__compiledResults.txt but when I load that into R.

mydata = read.table("all_SRST2_compiledResults.txt") Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 23 did not have 70 elements

So I figure I would trim the file to just the sample names, ST column and 7 MLST genes. I call this ST_Results. I attempt to remove the blanks and the - marks but I still get this error.

mydata = read.table("ST_Results.txt") Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 23 did not have 9 elements

Could you point me to an example of the input file?

Best, Paola

paolaflorez commented 9 years ago

Hello Kat, It has clearly been a while since I used R. I remember now that I need to read in a csv file (as you also mention in the srst2/scripts home page. However, now the file is ok, but I ran through the whole code and there are still no graphs. Do I need to load a package plotSRST2data.R? I thought maybe your readme commands were the package but clearly I'm missing something.

Best, Paola

paolaflorez commented 9 years ago

Hello,

I managed to get about a 1/3 of the way through the script to the geneSTplot portion. I wanted to point out and error in the R code paste is listed as paste0, which is incorrect. I was wondering will the rest of the plotSRST2data.R actually plot of the antibiotic resistance portion of the table?

Best, Paola

katholt commented 9 years ago

Hi Paola,

I’m away on a retreat this week and won’t be able to post step by step instructions for the plotting for a while.

However, the basic process is:

load the scripts into R

source("../srst2/scripts/plotSRST2data.R”)

read table into R

d<-read.delim("test__compiledResults.txt", stringsAsFactors = F)

make plots

geneCountPlot(d,mlst_columns=2:9,gene_columns=19:63)

geneRatePlot(d,mlst_columns=2:9,gene_columns=19:63)

plotTreeData(as.phylo(clusterByST(m[,mlst_columns[-1]])),matrixFile=binaryMatrix(m[,gene_columns]),infoFile=m[,mlst_columns], matrix.colours=c(0,1),tip.labels=F,infoCex=1,dataWidth=20,cluster=T,labelHeight=20,colLabelCex=1,freqWidth=0)