enter image description here
I'm trying to use "Seurat" to analyze B cells for my tutor, but the following error occurs when I try to create the object and I don't know how to correct it.
pbmc <- CreateSeuratObject( counts = BC.data$'B Cells`, Project = " BC.data",min.cells = 3, min.features = 200)
Error in UseMethod(generic = "as.sparse", object = x) :
no applicable method for 'as.sparse' applied to an object of class "Seurat"
Related
I want to do a radiometric correction of a landsat image using:
radiocorr(x, gain, offset, Grescale, Brescale, sunelev, satzenith, edist, Esun,
Lhaze, method = "apparentreflectance")
I performed the correction to each band, as follow:
B1 <- readGDAL("_X20060509_B_1.tif")
B1.ar<-radiocorr(x = B1, Grescale = 0.76583, Brescale = -2.28583, sunelev = 43.99853366,
satzenith = 0, edist = 1.0095786, Esun = 1983, method = "apparentreflectance")
writeGDAL(B1.ar, "C:/Users/Documents/ Reflectance/B1.tif", drivername="GTiff")
How can I make one function to automatically perform the correction to the six bands?
I tried with this function:
atmcor <- function(img, i) {
x<-img[[i]]
Grescale<-gain[i,2]
Brescale<-bias[i,2]
sunelev<-sunelevation[i,2]
satzenith=0
edist<-edistance[i,2]
Esun<-Esun[1,2]
method = "apparentreflectance"
B.ar<-radiocorr(x, Grescale, Brescale, sunelev, satzenith, edist, Esun, method)
return(B.ar)
}
ATMCOR <- atmcor(landsat_stack, 1)
But, I got this error:
(Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x), :
length of 'dimnames' [1] not equal to array extent)
If you want to do the radiometric calibration for all bands in only one execution chunk you need to load your metadata file as well.
Therefore you can do it in several forms. But the following code can easily solve your problem.
radCor(img, metaData, method = "apref", bandSet = "full", hazeValues,
hazeBands, atmosphere, darkProp = 0.01, clamp = TRUE, verbose)
When you set the bandSet to "full", all the band in the solar region will be processed.
Here is my code to genrate sequence of numbers. The sequence starts from 3 and stops at the sqaure root of a number input by user.
num = as.numeric(readline(prompt = "Enter a number :"))
mysqrt = as.integer(sqrt(num))
myseq = seq(from = 3,to = mysqrt, by = 2)
The error I get is ->
Error in seq.default(from = 3, to = mysqrt, by = 2) :
wrong sign in 'by' argument
If i run ->
seq(3,as.integer(sqrt(25)), by = 2)
it works fine as expected.
If i run ->
num = 25
seq(3,as.integer(sqrt(num)), by = 2)
it gives the above error.
I am doing association analysis using R.
This is the code I am using to generate rules:
rules <- apriori(trans, parameter = list(supp = .07,conf = 0.50,smax=6,minlen=3,maxlen=9,target = "rules"))
This code is giving me the set of rules for the given dataset, however if I try to find rules for particular consequent then I am getting an error.
Here is the code:
rules2 <- apriori(data=trans,parameter=list(supp = .07,conf = 0.5,smax=6,minlen=3,maxlen=9,target = "rules"),
appearance = list(default="lhs",rhs="CMDB"),
control = list(verbose=F))
and this is the error I am getting :
"Error in asMethod(object) : CMDB is an unknown item label"
How do I generate the correct rule?
Thanks.
You should write like this
appearance=list(rhs=c("CMDB"))
I've got this small snippet for reducing a large system:
# set up the multipliers
g1 = (s+9)/((s)*(s+6)*(s+12)*(s+14))
g2 = ((6)*(s+9)*(s+17))/((s+12)*(s+32)*(s+68))
h1 = 13
h2 = 1/(s+7)
# reduce the system in parts
s1 = (g2)/(1 + (g2)*(h1))
s2 = (s1)*(g1)
s3 = (s2)/(1 + (s2)*(h2))
# now we have a unity feedback
g = s3
show(g)
g should be the reduced equation from doing the operations above. However, I get a bunch of errors when I run the code:
Error : object 's' not found
Error : object 's' not found
Error : object 's' not found
Error : object 'g2' not found
Error : object 's1' not found
Error : object 's2' not found
Error : object 's3' not found
Error : error in evaluating the argument 'object' in selecting a method for function 'show': Error: object 'g' not found
Am I not using equations correctly?
edit: my intentions are to have s as a free variable
In order to evaluate your first line of code, there must be an object s that is already defined.
It sounds like your goal is to create a function that outputs g from a single input s. The below code wraps your calculations in a function called make_g:
make_g <- function(s){
# set up the multipliers
g1 = (s+9)/((s)*(s+6)*(s+12)*(s+14))
g2 = ((6)*(s+9)*(s+17))/((s+12)*(s+32)*(s+68))
h1 = 13
h2 = 1/(s+7)
# reduce the system in parts
s1 = (g2)/(1 + (g2)*(h1))
s2 = (s1)*(g1)
s3 = (s2)/(1 + (s2)*(h2))
# now we have a unity feedback
g = s3
g
}
Now, you can call the functions using whatever value for s you like:
make_g(s = 1)
I have already discussed a similar type of a question in this following post
How to set a for -loop in R
each file contents as follows:
FILE_1.FASTA
>>TTBK2_Hsap ,(CK1/TTBK)
MSGGGEQLDILSVGILVKERWKVLRKIGGGGFGEIYDALDMLTRENVALKVESAQQPKQVLKMEVAVLKKLQGKDHVCRFIGCGRNDRFNYVVMQLQGRNLADLRRSQSRGTFT
FILE_2.FASTA
>>TTBK2_Hsap ,(CK1/TTBK)
MSGGGEQLDILSVGILVKERWKVLRKIGGGGFGEIYDALDMLTRENVALKVESAQQPKQVLKMEVAVLKKLQGKDHVCRFIGCGRNDRFNYVVMQLQGRNLADLRRSQSRGTFT
However, there is another package in R which works like this:
extractAPAAC(x, props = c("Hydrophobicity", "Hydrophilicity"), lambda = 30,
w = 0.05, customprops = NULL)
I tried creating a function to run it for number of file sequences and the program looks like this
read_and_extract <- function(fasta) {
seq <- readFASTA(fasta)[[1]]
return(extractAPAAC(seq, props = c("Hydrophobicity", "Hydrophilicity"), lambda = 30,
w = 0.05, customprops = NULL))
}
setwd("H:\\CC")
fasta_files <- dir(pattern = "[.]fasta$")
aa_comp <- vapply(fasta_files, read_and_extract, rep(pi, 80))
write.csv(aa_comp, file = "C:\\Users\\PAAC.csv")
This programs shows an error
Error: unexpected ',' in "w = 0.05,"
But I have given w=0.05 as of default value, could anyone tell me where is the actual problem?