Commit 81a6528e authored by svolant's avatar svolant
Browse files

bug fix read target file

parent cf10eaf7
......@@ -123,7 +123,6 @@ CheckTargetModel <- function(input,target,labeled,CT)
HowTo = "Add at least one variable in the 'Select the variables' widget"
}
## Names of samples correct ?
if(is.null(Error) && labeled==0){
Error = "The names of the samples in the target file do not fit the counts table"
......@@ -134,8 +133,13 @@ CheckTargetModel <- function(input,target,labeled,CT)
if(is.null(Error) && ncol(target)<2){
Error = "The number of columns of the target file must be at least 2"
HowTo = "Add at least one additional variable to describe your samples"
}
}
if(is.null(Error) && min(sapply(apply(target,2,unique),length)) <=1){
Error = "One of the variable has the same value for all the samples"
HowTo = "Remove the variable from the target file"
}
## Number of rows
if(is.null(Error) && nrow(target)<=1){
......
......@@ -480,46 +480,50 @@ shinyServer(function(input, output,session) {
inFile <- input$fileTarget
counts = dataInput()$data$counts
labeled = 0
if (is.null(inFile)) return(NULL)
## Read the data
try(read.csv(inFile$datapath,sep=input$septarget,header=TRUE)->data,silent=TRUE)
data = read.csv(inFile$datapath,sep=input$septarget,header=TRUE)
data = as.data.frame(data)
names = colnames(data)
## Change the rownames
rownames(data) <- as.character(data[, 1])
## Keep only the row which are in the count table
ind = which(rownames(data)%in%colnames(counts))
data = as.data.frame(data[ind,])
colnames(data) = names
## Replace "-" by "."
if(ncol(data)>1 && nrow(data)>1){
ind_num = which(sapply(as.data.frame(data[,-1]),is.numeric)) + 1
if(length(ind_num)>0){
data_tmp =cbind( as.data.frame(apply(as.data.frame(data[,-ind_num]),2,gsub,pattern = "-",replacement = ".")),data[,ind_num])
colnames(data_tmp) = c(colnames(data)[-ind_num],colnames(data)[ind_num])
data = data_tmp
if(!is.null(data))
{
data = as.data.frame(data)
names = colnames(data)
## Change the rownames
rownames(data) <- as.character(data[, 1])
## Keep only the row which are in the count table
ind = which(rownames(data)%in%colnames(counts))
data = as.data.frame(data[ind,])
colnames(data) = names
## Replace "-" by "."
if(ncol(data)>1 && nrow(data)>1){
ind_num = which(sapply(as.data.frame(data[,-1]),is.numeric)) + 1
if(length(ind_num)>0){
data_tmp =cbind( as.data.frame(apply(as.data.frame(data[,-ind_num]),2,gsub,pattern = "-",replacement = ".")),data[,ind_num])
colnames(data_tmp) = c(colnames(data)[-ind_num],colnames(data)[ind_num])
data = data_tmp
}
if(length(ind_num)==0){data = as.data.frame(apply(data,2,gsub,pattern = "-",replacement = "."))}
}
if(length(ind_num)==0){data = as.data.frame(apply(data,2,gsub,pattern = "-",replacement = "."))}
target = as.data.frame(data)
# target = as.data.frame(apply(target,2,gsub,pattern = "-",replacement = "."))
#ord = order(rownames(data))
#data = data[ord,]
### A SUPPRIMER
#rownames(data) <- colnames(counts)
# Percent annotated
# print(ind)
# print(colnames(counts))
# print(rownames(data))
labeled = length(ind)/length(colnames(counts))*100.0
}
target = as.data.frame(data)
# target = as.data.frame(apply(target,2,gsub,pattern = "-",replacement = "."))
#ord = order(rownames(data))
#data = data[ord,]
### A SUPPRIMER
#rownames(data) <- colnames(counts)
# Percent annotated
# print(ind)
# print(colnames(counts))
# print(rownames(data))
labeled = length(ind)/length(colnames(counts))*100.0
return(list(target = target, labeled=labeled))
})
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment