if else statement for Oncoprint
1
0
Entering edit mode
4.1 years ago
ngcatung0 ▴ 20

I encountered this code from the Oncoprint supplementary code:

amp = ifelse(apply(mat, 1, function(x) sum(grepl("AMP", x))/length(x) > 0.1), "high AMP events", "low AMP events")
amp = factor(amp, levels = c("low AMP events", "high AMP events"))

Which is meant to split the genes into 2 groups based on the amplification rate across patients. The variable amp contains labels for genes indicating which group they are in. amp is converted to a factor to control the order of two row-slices on the plot.

Im trying to reformat it so that it can split the genes into good responders and poor responders, so its essentially 3 conditions where the genes involved with good responders, genes involved with poor responders and genes involved with both. (FYI, Good responders = 1, Poor responders = 3)

This is my attempt:

ifelse(apply(response_level, 1, function(x) sum(grep("1"&&"3", "Mixed, ifelse(apply(response_level, 1, function(x) sum(grepl("1", "Good 1", "Poor 3"))

> Error: unexpected numeric constant in "response_level = ifelse(apply(response_level, 1, function(x) sum(grep("1"&&"3", "Mixed, ifelse(apply(response_level, 1, function(x) sum(grepl("1"
R Genomics Oncoprint ifelse • 775 views
ADD COMMENT
1
Entering edit mode
4.1 years ago
zx8754 11k

Run you code bit by bit. There is a quote " missing around "Mixed, grep command doesn't look right, test if the apply statements run without errors. Try to debug. Also, provide example input data and expected output.

ADD COMMENT

Login before adding your answer.

Traffic: 1799 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6